Exemplo n.º 1
0
def makeThr(segID: int, N, CA, C, O, geo: ThrGeo) -> Residue:
    """Creates a Threonine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_OG1_length = geo.CB_OG1_length
    CA_CB_OG1_angle = geo.CA_CB_OG1_angle
    N_CA_CB_OG1_diangle = geo.N_CA_CB_OG1_diangle

    CB_CG2_length = geo.CB_CG2_length
    CA_CB_CG2_angle = geo.CA_CB_CG2_angle
    N_CA_CB_CG2_diangle = geo.N_CA_CB_CG2_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    oxygen_g1 = calculateCoordinates(N, CA, CB, CB_OG1_length, CA_CB_OG1_angle,
                                     N_CA_CB_OG1_diangle)
    OG1 = Atom("OG1", oxygen_g1, 0.0, 1.0, " ", " OG1", 0, "O")
    carbon_g2 = calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle,
                                     N_CA_CB_CG2_diangle)
    CG2 = Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C")

    res = Residue((" ", segID, " "), "THR", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(OG1)
    res.add(CG2)
    return res
Exemplo n.º 2
0
def makePro(segID, N, CA, C, O, geo):
    '''Creates a Proline residue'''
    ##R-Group
    CA_CB_length=geo.CA_CB_length
    C_CA_CB_angle=geo.C_CA_CB_angle
    N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle
    
    CB_CG_length=geo.CB_CG_length
    CA_CB_CG_angle=geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle
    
    CG_CD_length=geo.CG_CD_length
    CB_CG_CD_angle=geo.CB_CG_CD_angle
    CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle
    
    carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle)
    CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C")
    carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle)
    CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle)
    CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C")

    ##Create Residue Data Structure
    res= Residue((' ', segID, ' '), "PRO", '    ')
    
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(CD)

    return res
Exemplo n.º 3
0
def makeCys(segID: int, N, CA, C, O, geo: CysGeo) -> Residue:
    """Creates a Cysteine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_SG_length = geo.CB_SG_length
    CA_CB_SG_angle = geo.CA_CB_SG_angle
    N_CA_CB_SG_diangle = geo.N_CA_CB_SG_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    sulfur_g = calculateCoordinates(N, CA, CB, CB_SG_length, CA_CB_SG_angle,
                                    N_CA_CB_SG_diangle)
    SG = Atom("SG", sulfur_g, 0.0, 1.0, " ", " SG", 0, "S")

    res = Residue((" ", segID, " "), "CYS", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(SG)
    return res
    def __init__(
        self,
        idcode,
        model,
        name,
        x,
        y,
        z,
        bfactor,
        occupancy,
        altloc,
        fullname,
        serial_number,
        idamino,
        resseq,
        icode,
        chainid,
        segid,
        resName=None,
    ):
        coord = coord = numpy.array((x, y, z), "f")

        Atom.__init__(self, str(name), coord, bfactor, occupancy, str(altloc), str(fullname), int(serial_number))
        self._model = model
        self._idcode = idcode
        self._idamino = idamino
        self._resseq = resseq
        self._icode = str(icode)
        self._chainid = str(chainid)
        self._segid = segid
        # Used when we have the resname.
        self._resname = resName
Exemplo n.º 5
0
def makeSer(segID: int, N, CA, C, O, geo: SerGeo) -> Residue:
    """Creates a Serine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_OG_length = geo.CB_OG_length
    CA_CB_OG_angle = geo.CA_CB_OG_angle
    N_CA_CB_OG_diangle = geo.N_CA_CB_OG_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    oxygen_g = calculateCoordinates(N, CA, CB, CB_OG_length, CA_CB_OG_angle,
                                    N_CA_CB_OG_diangle)
    OG = Atom("OG", oxygen_g, 0.0, 1.0, " ", " OG", 0, "O")

    ##Create Reside Data Structure
    res = Residue((" ", segID, " "), "SER", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(OG)
    return res
Exemplo n.º 6
0
def makeThr(segID, N, CA, C, O, geo):
    '''Creates a Threonine residue'''
    ##R-Group
    CA_CB_length=geo.CA_CB_length
    C_CA_CB_angle=geo.C_CA_CB_angle
    N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle
    
    CB_OG1_length=geo.CB_OG1_length
    CA_CB_OG1_angle=geo.CA_CB_OG1_angle
    N_CA_CB_OG1_diangle=geo.N_CA_CB_OG1_diangle 
        
    CB_CG2_length=geo.CB_CG2_length
    CA_CB_CG2_angle=geo.CA_CB_CG2_angle
    N_CA_CB_CG2_diangle= geo.N_CA_CB_CG2_diangle

    carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle)
    CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C")
    oxygen_g1= calculateCoordinates(N, CA, CB, CB_OG1_length, CA_CB_OG1_angle, N_CA_CB_OG1_diangle)
    OG1= Atom("OG1", oxygen_g1, 0.0, 1.0, " ", " OG1", 0, "O")
    carbon_g2= calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle, N_CA_CB_CG2_diangle)
    CG2= Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C")

    ##Create Residue Data Structure
    res= Residue((' ', segID, ' '), "THR", '    ')
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(OG1)
    res.add(CG2)
    return res
Exemplo n.º 7
0
def makeCys(segID, N, CA, C, O, geo):
    '''Creates a Cysteine residue'''
    ##R-Group
    CA_CB_length=geo.CA_CB_length
    C_CA_CB_angle=geo.C_CA_CB_angle
    N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle
    
    CB_SG_length= geo.CB_SG_length
    CA_CB_SG_angle= geo.CA_CB_SG_angle
    N_CA_CB_SG_diangle= geo.N_CA_CB_SG_diangle

    carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle)
    CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C")
    sulfur_g= calculateCoordinates(N, CA, CB, CB_SG_length, CA_CB_SG_angle, N_CA_CB_SG_diangle)
    SG= Atom("SG", sulfur_g, 0.0, 1.0, " ", " SG", 0, "S")

    ##Create Residue Data Structure
    res= Residue((' ', segID, ' '), "CYS", '    ')
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(SG)
    return res
Exemplo n.º 8
0
def makeVal(segID: int, N, CA, C, O, geo: ValGeo) -> Residue:
    """Creates a Valine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_CG1_length = geo.CB_CG1_length
    CA_CB_CG1_angle = geo.CA_CB_CG1_angle
    N_CA_CB_CG1_diangle = geo.N_CA_CB_CG1_diangle

    CB_CG2_length = geo.CB_CG2_length
    CA_CB_CG2_angle = geo.CA_CB_CG2_angle
    N_CA_CB_CG2_diangle = geo.N_CA_CB_CG2_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    carbon_g1 = calculateCoordinates(N, CA, CB, CB_CG1_length, CA_CB_CG1_angle,
                                     N_CA_CB_CG1_diangle)
    CG1 = Atom("CG1", carbon_g1, 0.0, 1.0, " ", " CG1", 0, "C")
    carbon_g2 = calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle,
                                     N_CA_CB_CG2_diangle)
    CG2 = Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C")

    ##Create Residue Data Structure
    res = Residue((" ", segID, " "), "VAL", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG1)
    res.add(CG2)
    return res
Exemplo n.º 9
0
def retrieve_ca_model(structure):
    """
    chains are represented only by main chain atoms (Calfas or C4')
    """
    reduced_struct = Structure('clustering_model')
    my_model = Model(0)
    reduced_struct.add(my_model)

    main_chain_atoms = []
    for ch in structure[0]:
        my_chain = Chain(ch.id)
        reduced_struct[0].add(my_chain)
        for resi in ch:
            for atom in resi:
                #print "----", resi.id, resi.get_segid(), ch.id
                if atom.get_name() == "CA" or atom.get_name(
                ) == "C4'" or atom.get_name() == "C4*":
                    my_residue = Residue((' ', resi.id[1], ' '),
                                         resi.get_resname(), ' ')
                    atom = Atom('CA', atom.coord, 0, ' ', ' ', 'CA',
                                atom.get_serial_number())
                    my_chain.add(my_residue)
                    my_residue.add(atom)

                    main_chain_atoms.append(atom)

    return reduced_struct
Exemplo n.º 10
0
def initialize_res(residue: Union[Geo, str]) -> Structure:
    """Creates a new structure containing a single amino acid. The type and
    geometry of the amino acid are determined by the argument, which has to be
    either a geometry object or a single-letter amino acid code.
    The amino acid will be placed into chain A of model 0."""

    if isinstance(residue, Geo):
        geo = residue
    elif isinstance(residue, str):
        geo = geometry(residue)
    else:
        raise ValueError("Invalid residue argument:", residue)

    segID = 1
    AA = geo.residue_name
    CA_N_length = geo.CA_N_length
    CA_C_length = geo.CA_C_length
    N_CA_C_angle = geo.N_CA_C_angle

    CA_coord = np.array([0.0, 0.0, 0.0])
    C_coord = np.array([CA_C_length, 0, 0])
    N_coord = np.array([
        CA_N_length * math.cos(N_CA_C_angle * (math.pi / 180.0)),
        CA_N_length * math.sin(N_CA_C_angle * (math.pi / 180.0)),
        0,
    ])

    N = Atom("N", N_coord, 0.0, 1.0, " ", " N", 0, "N")

    # Check if the peptide is capped or not
    if geo.residue_name == "ACE":
        CA = Atom("CH3", CA_coord, 0.0, 1.0, " ", " CH3", 0, "C")
    else:
        CA = Atom("CA", CA_coord, 0.0, 1.0, " ", " CA", 0, "C")

    C = Atom("C", C_coord, 0.0, 1.0, " ", " C", 0, "C")

    ##Create Carbonyl atom (to be moved later)
    C_O_length = geo.C_O_length
    CA_C_O_angle = geo.CA_C_O_angle
    N_CA_C_O_diangle = geo.N_CA_C_O_diangle

    carbonyl = calculateCoordinates(N, CA, C, C_O_length, CA_C_O_angle,
                                    N_CA_C_O_diangle)
    O = Atom("O", carbonyl, 0.0, 1.0, " ", " O", 0, "O")

    res = make_res_of_type(segID, N, CA, C, O, geo)

    cha = Chain("A")
    cha.add(res)

    mod = Model(0)
    mod.add(cha)

    struc = Structure("X")
    struc.add(mod)
    return struc
Exemplo n.º 11
0
def addHydrogens(residue, last_c=None, last_no=None):
    ''' Add hydrogens to a given residue, renumbering atoms appropriately. Will also convert disordered atoms into their respective first representatives.'''
    rname = residue.resname
    new_atoms = []
    if last_no is None:
        last_no = 0
    if rname in fix_dispatch:
        fr = fix_dispatch[rname]
        for atom in list(residue):
            name = atom.id
            atom.serial_number = last_no            
            new_atoms.append( (name, atom) )
            last_no+=1
            # Special case is the hydrogen on peptide backbone - dispatch manually depending on last_c
            # Proline skips this step
            if name=='N' and rname!='PRO' and last_c is not None and 'CA' in residue.child_dict and 'N' in residue.child_dict:
                nname = ' H  '
                b_factor = 0.0
                occupancy = 1.0
                altloc = ' '
                fullname = name
                coords = fix0(residue['N'], last_c, residue['CA'])[0]
                new_atom = Atom(nname.strip(), coords, b_factor, occupancy, altloc, nname, last_no) 
                last_no+=1
                new_atoms.append( (new_atom.id, new_atom) )
                residue.add(new_atom)
            else:
                if name in fr:
                    f = fr[name]
                    # Sometimes a third atom is needed
                    f_delta3 = getattr(f, 'delta3', None)
                    # Check all atoms needed for adding are in place
                    if f.delta1 in residue.child_dict and f.delta2 in residue.child_dict and (f_delta3 is None or f_delta3 in residue.child_dict):
                        fixed = f.fix(atom, residue[f.delta1], residue[f.delta2], (residue[f_delta3] if f_delta3 else None))
                        # Create names according to standard - prefix is only added if more than one hydrogen is introduced
                        if len(fixed)>1:
                            names = ['%dH%s' % (i+1, atom.fullname[2:]) for i in range(0,len(fixed)) ]
                        else:
                            names = [' H%s' % atom.fullname[2:] ]
                        for nname, coords in zip(names, fixed):
                            b_factor = 0.0
                            occupancy = 1.0
                            altloc = ' '
                            fullname = name
                            new_atom = Atom(nname.strip(), coords, b_factor, occupancy, altloc, nname, last_no) 
                            last_no+=1
                            new_atoms.append( (new_atom.id, new_atom) )
                            residue.add(new_atom)
        # Restructure child lists to preserve new atom order
        residue.child_list = [v[1] for v in new_atoms]
        residue.child_dict = dict(new_atoms)
    if new_atoms:
        return new_atoms, last_no
    else:
        return None, last_no
Exemplo n.º 12
0
    def __init__(self, name, coord, bfactor, occupancy, altloc, fullname, \
        serial_number, element=None, mol_weight = None, vdw=None, density=None,\
 state = None, index = None, atom_type = None):

        self.vdw = None  #VanderWaals radius for given atom
        self.molweight = None  #molecular weight of given atom
        self.state = "free"  #free/fixed
        self.index = 0  #index assigned during pseudoatoms modeling
        self.atom_type = "regular"  #regular/pseudo
        Atom.__init__(self, name, coord, bfactor, occupancy, \
                      altloc, fullname, serial_number, element)
Exemplo n.º 13
0
def makeGln(segID: int, N, CA, C, O, geo: GlnGeo) -> Residue:
    """Creates a Glutamine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_CG_length = geo.CB_CG_length
    CA_CB_CG_angle = geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle = geo.N_CA_CB_CG_diangle

    CG_CD_length = geo.CG_CD_length
    CB_CG_CD_angle = geo.CB_CG_CD_angle
    CA_CB_CG_CD_diangle = geo.CA_CB_CG_CD_diangle

    CD_OE1_length = geo.CD_OE1_length
    CG_CD_OE1_angle = geo.CG_CD_OE1_angle
    CB_CG_CD_OE1_diangle = geo.CB_CG_CD_OE1_diangle

    CD_NE2_length = geo.CD_NE2_length
    CG_CD_NE2_angle = geo.CG_CD_NE2_angle
    CB_CG_CD_NE2_diangle = geo.CB_CG_CD_NE2_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    carbon_g = calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle,
                                    N_CA_CB_CG_diangle)
    CG = Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    carbon_d = calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle,
                                    CA_CB_CG_CD_diangle)
    CD = Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C")
    oxygen_e1 = calculateCoordinates(CB, CG, CD, CD_OE1_length,
                                     CG_CD_OE1_angle, CB_CG_CD_OE1_diangle)
    OE1 = Atom("OE1", oxygen_e1, 0.0, 1.0, " ", " OE1", 0, "O")
    nitrogen_e2 = calculateCoordinates(CB, CG, CD, CD_NE2_length,
                                       CG_CD_NE2_angle, CB_CG_CD_NE2_diangle)
    NE2 = Atom("NE2", nitrogen_e2, 0.0, 1.0, " ", " NE2", 0, "N")

    ##Create Residue DS
    res = Residue((" ", segID, " "), "GLN", "    ")

    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(CD)
    res.add(OE1)
    res.add(NE2)
    return res
Exemplo n.º 14
0
def makeLys(segID: int, N, CA, C, O, geo: LysGeo) -> Residue:
    """Creates a Lysine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_CG_length = geo.CB_CG_length
    CA_CB_CG_angle = geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle = geo.N_CA_CB_CG_diangle

    CG_CD_length = geo.CG_CD_length
    CB_CG_CD_angle = geo.CB_CG_CD_angle
    CA_CB_CG_CD_diangle = geo.CA_CB_CG_CD_diangle

    CD_CE_length = geo.CD_CE_length
    CG_CD_CE_angle = geo.CG_CD_CE_angle
    CB_CG_CD_CE_diangle = geo.CB_CG_CD_CE_diangle

    CE_NZ_length = geo.CE_NZ_length
    CD_CE_NZ_angle = geo.CD_CE_NZ_angle
    CG_CD_CE_NZ_diangle = geo.CG_CD_CE_NZ_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    carbon_g = calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle,
                                    N_CA_CB_CG_diangle)
    CG = Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    carbon_d = calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle,
                                    CA_CB_CG_CD_diangle)
    CD = Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C")
    carbon_e = calculateCoordinates(CB, CG, CD, CD_CE_length, CG_CD_CE_angle,
                                    CB_CG_CD_CE_diangle)
    CE = Atom("CE", carbon_e, 0.0, 1.0, " ", " CE", 0, "C")
    nitrogen_z = calculateCoordinates(CG, CD, CE, CE_NZ_length, CD_CE_NZ_angle,
                                      CG_CD_CE_NZ_diangle)
    NZ = Atom("NZ", nitrogen_z, 0.0, 1.0, " ", " NZ", 0, "N")

    ##Create Residue Data Structure
    res = Residue((" ", segID, " "), "LYS", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(CD)
    res.add(CE)
    res.add(NZ)
    return res
Exemplo n.º 15
0
def add_residue_from_geo(structure, geo):
    '''Adds a residue to chain A model 0 of the given structure, and
    returns the new structure. The residue to be added is determined by
    the geometry object given as second argument.
    
    This function is a helper function and should not normally be called
    directly. Call add_residue() instead.'''
    resRef= getReferenceResidue(structure)
    AA=geo.residue_name
    segID= resRef.get_id()[1]
    segID+=1

    ##geometry to bring together residue
    peptide_bond=geo.peptide_bond
    CA_C_N_angle=geo.CA_C_N_angle
    C_N_CA_angle=geo.C_N_CA_angle

    ##Backbone Coordinages
    N_CA_C_angle=geo.N_CA_C_angle
    CA_N_length=geo.CA_N_length
    CA_C_length=geo.CA_C_length
    phi= geo.phi
    psi_im1=geo.psi_im1
    omega=geo.omega

    N_coord=calculateCoordinates(resRef['N'], resRef['CA'], resRef['C'], peptide_bond, CA_C_N_angle, psi_im1)
    N= Atom("N", N_coord, 0.0 , 1.0, " "," N", 0, "N")

    CA_coord=calculateCoordinates(resRef['CA'], resRef['C'], N, CA_N_length, C_N_CA_angle, omega)
    CA=Atom("CA", CA_coord, 0.0 , 1.0, " "," CA", 0,"C")

    C_coord=calculateCoordinates(resRef['C'], N, CA, CA_C_length, N_CA_C_angle, phi)
    C= Atom("C", C_coord, 0.0, 1.0, " ", " C",0,"C")

    ##Create Carbonyl atom (to be moved later)
    C_O_length=geo.C_O_length
    CA_C_O_angle=geo.CA_C_O_angle
    N_CA_C_O_diangle=geo.N_CA_C_O_diangle

    carbonyl=calculateCoordinates(N, CA, C, C_O_length, CA_C_O_angle, N_CA_C_O_diangle)
    O= Atom("O",carbonyl , 0.0 , 1.0, " "," O", 0, "O")
    
    res=makeRes(segID, N, CA, C, O, geo)
        
    resRef['O'].set_coord(calculateCoordinates(res['N'], resRef['CA'], resRef['C'], C_O_length, CA_C_O_angle, 180.0))

    ghost= Atom("N", calculateCoordinates(res['N'], res['CA'], res['C'], peptide_bond, CA_C_N_angle, psi_im1), 0.0 , 0.0, " ","N", 0, "N")
    res['O'].set_coord(calculateCoordinates( res['N'], res['CA'], res['C'], C_O_length, CA_C_O_angle, 180.0))

    structure[0]['A'].add(res)
    return structure
Exemplo n.º 16
0
def insert_missing_residues(residues, parse_info):
    """
    Create a fake residue to fill in
    missing residues. The xyz coordinates will
    be infinity (so it will always output no contact).

    :param residues: list of only residues
    :type  residues: list
    :param parse_info: dictionary mapping extracted info to its info
    :type  parse_info: dict
    :returns: list of residues with inserts
    :rtype:   list
    """

    new_residues = residues
    missing_resid_position = parse_info["Missing Residues"]

    for position in missing_resid_position:
        new_residue = Residue((' ', position, ' '), "GLY", '    ')
        new_atom = Atom(
            name="CA",
            coord=np.array([np.inf, np.inf, np.inf]),
            bfactor=0,
            occupancy=0,
            altloc=' ',
            fullname=" CA ",
            serial_number=0
        )
        new_residue.add(new_atom)
        new_residues.append(new_residue)

    new_residues.sort()
    return new_residues
    def create_sphere_representation(self):
        """
	each chain is here represented by centre of mass only
	"""
        new_struct = Structure('sphrere')
        my_model = Model(0)
        new_struct.add(my_model)

        chain_mass_centres, index = [], 1
        my_chain = Chain(self.fa_struct.chain)
        new_struct[0].add(my_chain)

        coord, self.molmass, self.radius = self.calculate_centre_of_complex(
            self.fa_struct.struct)
        my_residue = Residue((' ', index, ' '), "ALA", ' ')

        coords = array(coord, 'f')
        atom = Atom('CA', coords, 0, 0, ' ', ' CA', 1)

        my_chain.add(my_residue)
        my_residue.add(atom)

        self.cg_struct = new_struct
        name = "dddd" + self.fa_struct.chain
        self.save_pdb(new_struct, name)
Exemplo n.º 18
0
def retrieve_sphere_model(structure):  #, score):
    """
    each chain is here represented by centre of mass only
    """
    sphere_struct = Structure('clustering_model')
    my_model = Model(0)
    sphere_struct.add(my_model)

    #bedzie zmieniona numeracja
    chain_mass_centres, index = [], 0
    for chain in structure.get_chains():
        my_chain = Chain(chain.id)
        sphere_struct[0].add(my_chain)

        coord = calculate_centre_of_complex(chain)
        chain_mass_centres.append(coord)
        my_residue = Residue((' ', index, ' '), chain.id, ' ')

        coords = array(coord, 'f')
        atom = Atom('CA', coords, 0, 0, ' ', 'CA', 1)

        my_chain.add(my_residue)
        my_residue.add(atom)

        index += 1
    del structure
    return sphere_struct
Exemplo n.º 19
0
def makeGlu(segID, N, CA, C, O, geo):
    '''Creates a Glutamic Acid residue'''
    ##R-Group
    CA_CB_length=geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle
    
    CB_CG_length=geo.CB_CG_length
    CA_CB_CG_angle=geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle

    CG_CD_length=geo.CG_CD_length
    CB_CG_CD_angle=geo.CB_CG_CD_angle
    CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle

    CD_OE1_length=geo.CD_OE1_length
    CG_CD_OE1_angle=geo.CG_CD_OE1_angle
    CB_CG_CD_OE1_diangle=geo.CB_CG_CD_OE1_diangle

    CD_OE2_length=geo.CD_OE2_length
    CG_CD_OE2_angle=geo.CG_CD_OE2_angle
    CB_CG_CD_OE2_diangle=geo.CB_CG_CD_OE2_diangle

    carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle)
    CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C")
    carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle)
    CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle)
    CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C")
    oxygen_e1= calculateCoordinates(CB, CG, CD, CD_OE1_length, CG_CD_OE1_angle, CB_CG_CD_OE1_diangle)
    OE1= Atom("OE1", oxygen_e1, 0.0, 1.0, " ", " OE1", 0, "O")
    oxygen_e2= calculateCoordinates(CB, CG, CD, CD_OE2_length, CG_CD_OE2_angle, CB_CG_CD_OE2_diangle)
    OE2= Atom("OE2", oxygen_e2, 0.0, 1.0, " ", " OE2", 0, "O")

    ##Create Residue Data Structure
    res= Residue((' ', segID, ' '), "GLU", '    ')
    
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(CD)
    res.add(OE1)
    res.add(OE2)
    return res
Exemplo n.º 20
0
def makeArg(segID, N, CA, C, O, geo):
    '''Creates an Arginie residue'''
    ##R-Group
    CA_CB_length=geo.CA_CB_length
    C_CA_CB_angle=geo.C_CA_CB_angle
    N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle

    CB_CG_length=geo.CB_CG_length
    CA_CB_CG_angle= geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle
    
    CG_CD_length=geo.CG_CD_length
    CB_CG_CD_angle=geo.CB_CG_CD_angle
    CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle
    
    CD_NE_length=geo.CD_NE_length
    CG_CD_NE_angle=geo.CG_CD_NE_angle
    CB_CG_CD_NE_diangle=geo.CB_CG_CD_NE_diangle

    NE_CZ_length=geo.NE_CZ_length
    CD_NE_CZ_angle=geo.CD_NE_CZ_angle
    CG_CD_NE_CZ_diangle=geo.CG_CD_NE_CZ_diangle

    CZ_NH1_length=geo.CZ_NH1_length
    NE_CZ_NH1_angle=geo.NE_CZ_NH1_angle
    CD_NE_CZ_NH1_diangle=geo.CD_NE_CZ_NH1_diangle

    CZ_NH2_length=geo.CZ_NH2_length
    NE_CZ_NH2_angle=geo.NE_CZ_NH2_angle
    CD_NE_CZ_NH2_diangle=geo.CD_NE_CZ_NH2_diangle
    
    carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle)
    CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C")
    carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle)
    CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle)
    CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C")
    nitrogen_e= calculateCoordinates(CB, CG, CD, CD_NE_length, CG_CD_NE_angle, CB_CG_CD_NE_diangle)
    NE= Atom("NE", nitrogen_e, 0.0, 1.0, " ", " NE", 0, "N")
    carbon_z= calculateCoordinates(CG, CD, NE, NE_CZ_length, CD_NE_CZ_angle, CG_CD_NE_CZ_diangle)
    CZ= Atom("CZ", carbon_z, 0.0, 1.0, " ", " CZ", 0, "C")
    nitrogen_h1= calculateCoordinates(CD, NE, CZ, CZ_NH1_length, NE_CZ_NH1_angle, CD_NE_CZ_NH1_diangle)
    NH1= Atom("NH1", nitrogen_h1, 0.0, 1.0, " ", " NH1", 0, "N")
    nitrogen_h2= calculateCoordinates(CD, NE, CZ, CZ_NH2_length, NE_CZ_NH2_angle, CD_NE_CZ_NH2_diangle)
    NH2= Atom("NH2", nitrogen_h2, 0.0, 1.0, " ", " NH2", 0, "N")

    ##Create Residue Data Structure
    res= Residue((' ', segID, ' '), "ARG", '    ')
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(CD)
    res.add(NE)
    res.add(CZ)
    res.add(NH1)
    res.add(NH2)
    return res
Exemplo n.º 21
0
def makePhe(segID, N, CA, C, O, geo):
    '''Creates a Phenylalanine residue'''
    ##R-Group
    CA_CB_length=geo.CA_CB_length
    C_CA_CB_angle=geo.C_CA_CB_angle
    N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle
    
    CB_CG_length=geo.CB_CG_length
    CA_CB_CG_angle=geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle

    CG_CD1_length=geo.CG_CD1_length
    CB_CG_CD1_angle=geo.CB_CG_CD1_angle
    CA_CB_CG_CD1_diangle=geo.CA_CB_CG_CD1_diangle

    CG_CD2_length=geo.CG_CD2_length
    CB_CG_CD2_angle=geo.CB_CG_CD2_angle
    CA_CB_CG_CD2_diangle= geo.CA_CB_CG_CD2_diangle
    
    CD1_CE1_length=geo.CD1_CE1_length
    CG_CD1_CE1_angle=geo.CG_CD1_CE1_angle
    CB_CG_CD1_CE1_diangle=geo.CB_CG_CD1_CE1_diangle

    CD2_CE2_length=geo.CD2_CE2_length
    CG_CD2_CE2_angle=geo.CG_CD2_CE2_angle
    CB_CG_CD2_CE2_diangle=geo.CB_CG_CD2_CE2_diangle

    CE1_CZ_length=geo.CE1_CZ_length
    CD1_CE1_CZ_angle=geo.CD1_CE1_CZ_angle
    CG_CD1_CE1_CZ_diangle=geo.CG_CD1_CE1_CZ_diangle

    carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle)
    CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C")
    carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle)
    CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    carbon_d1= calculateCoordinates(CA, CB, CG, CG_CD1_length, CB_CG_CD1_angle, CA_CB_CG_CD1_diangle)
    CD1= Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C")
    carbon_d2= calculateCoordinates(CA, CB, CG, CG_CD2_length, CB_CG_CD2_angle, CA_CB_CG_CD2_diangle)
    CD2= Atom("CD2", carbon_d2, 0.0, 1.0, " ", " CD2", 0, "C")
    carbon_e1= calculateCoordinates(CB, CG, CD1, CD1_CE1_length, CG_CD1_CE1_angle, CB_CG_CD1_CE1_diangle)
    CE1= Atom("CE1", carbon_e1, 0.0, 1.0, " ", " CE1", 0, "C")
    carbon_e2= calculateCoordinates(CB, CG, CD2, CD2_CE2_length, CG_CD2_CE2_angle, CB_CG_CD2_CE2_diangle)
    CE2= Atom("CE2", carbon_e2, 0.0, 1.0, " ", " CE2", 0, "C")
    carbon_z= calculateCoordinates(CG, CD1, CE1, CE1_CZ_length, CD1_CE1_CZ_angle, CG_CD1_CE1_CZ_diangle)
    CZ= Atom("CZ", carbon_z, 0.0, 1.0, " ", " CZ", 0, "C")

    ##Create Residue Data Structures
    res= Residue((' ', segID, ' '), "PHE", '    ')
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(CD1)
    res.add(CE1)
    res.add(CD2)
    res.add(CE2)
    res.add(CZ)
    return res
Exemplo n.º 22
0
 def get_atoms(self):
     return [
         Atom(
             Vector3d(
                 list(at.get_vector())[0],
                 list(at.get_vector())[1],
                 list(at.get_vector())[2]), at.id, at.mass)
         for at in self.cg_atoms
     ]
Exemplo n.º 23
0
def initialize_res(residue):
    '''Creates a new structure containing a single amino acid. The type and
    geometry of the amino acid are determined by the argument, which has to be
    either a geometry object or a single-letter amino acid code.
    The amino acid will be placed into chain A of model 0.'''
    
    if isinstance( residue, Geo ):
        geo = residue
    else:
        geo= Geo(residue) 
    
    segID=1
    AA= geo.residue_name
    CA_N_length=geo.CA_N_length
    CA_C_length=geo.CA_C_length
    N_CA_C_angle=geo.N_CA_C_angle
    
    CA_coord= np.array([0.,0.,0.])
    C_coord= np.array([CA_C_length,0,0])
    N_coord = np.array([CA_N_length*math.cos(N_CA_C_angle*(math.pi/180.0)),CA_N_length*math.sin(N_CA_C_angle*(math.pi/180.0)),0])

    N= Atom("N", N_coord, 0.0 , 1.0, " "," N", 0, "N")
    CA=Atom("CA", CA_coord, 0.0 , 1.0, " "," CA", 0,"C")
    C= Atom("C", C_coord, 0.0, 1.0, " ", " C",0,"C")

    ##Create Carbonyl atom (to be moved later)
    C_O_length=geo.C_O_length
    CA_C_O_angle=geo.CA_C_O_angle
    N_CA_C_O_diangle=geo.N_CA_C_O_diangle
    
    carbonyl=calculateCoordinates(N, CA, C, C_O_length, CA_C_O_angle, N_CA_C_O_diangle)
    O= Atom("O",carbonyl , 0.0 , 1.0, " "," O", 0, "O")

    res=makeRes(segID, N, CA, C, O, geo)

    cha= Chain('A')
    cha.add(res)
    
    mod= Model(0)
    mod.add(cha)

    struc= Structure('X')
    struc.add(mod)
    return struc
Exemplo n.º 24
0
 def add_dummy_structure(self):
     """Adds a dummy atom of zero coordinates to mark a gap in visualisation
     software"""
     dummy_atom = Atom('DUM', np.zeros(3), 0, 1, ' ', 'DUM', -999)
     dummy_residue = Residue((' ', -1 * self.chiral_id, ' '), 'DUM', '?')
     dummy_residue.add(dummy_atom)
     dummy_chain = Chain('?')
     dummy_chain.add(dummy_residue)
     self.dummy_structure = dummy_residue
     return True
Exemplo n.º 25
0
def makeLeu(segID: int, N, CA, C, O, geo: LeuGeo) -> Residue:
    """Creates a Leucine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_CG_length = geo.CB_CG_length
    CA_CB_CG_angle = geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle = geo.N_CA_CB_CG_diangle

    CG_CD1_length = geo.CG_CD1_length
    CB_CG_CD1_angle = geo.CB_CG_CD1_angle
    CA_CB_CG_CD1_diangle = geo.CA_CB_CG_CD1_diangle

    CG_CD2_length = geo.CG_CD2_length
    CB_CG_CD2_angle = geo.CB_CG_CD2_angle
    CA_CB_CG_CD2_diangle = geo.CA_CB_CG_CD2_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    carbon_g1 = calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle,
                                     N_CA_CB_CG_diangle)
    CG = Atom("CG", carbon_g1, 0.0, 1.0, " ", " CG", 0, "C")
    carbon_d1 = calculateCoordinates(CA, CB, CG, CG_CD1_length,
                                     CB_CG_CD1_angle, CA_CB_CG_CD1_diangle)
    CD1 = Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C")
    carbon_d2 = calculateCoordinates(CA, CB, CG, CG_CD2_length,
                                     CB_CG_CD2_angle, CA_CB_CG_CD2_diangle)
    CD2 = Atom("CD2", carbon_d2, 0.0, 1.0, " ", " CD2", 0, "C")

    ##Create Residue Data Structure
    res = Residue((" ", segID, " "), "LEU", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(CD1)
    res.add(CD2)
    return res
Exemplo n.º 26
0
def makeIle(segID: int, N, CA, C, O, geo: IleGeo) -> Residue:
    """Creates an Isoleucine residue"""
    ##R-group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_CG1_length = geo.CB_CG1_length
    CA_CB_CG1_angle = geo.CA_CB_CG1_angle
    N_CA_CB_CG1_diangle = geo.N_CA_CB_CG1_diangle

    CB_CG2_length = geo.CB_CG2_length
    CA_CB_CG2_angle = geo.CA_CB_CG2_angle
    N_CA_CB_CG2_diangle = geo.N_CA_CB_CG2_diangle

    CG1_CD1_length = geo.CG1_CD1_length
    CB_CG1_CD1_angle = geo.CB_CG1_CD1_angle
    CA_CB_CG1_CD1_diangle = geo.CA_CB_CG1_CD1_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    carbon_g1 = calculateCoordinates(N, CA, CB, CB_CG1_length, CA_CB_CG1_angle,
                                     N_CA_CB_CG1_diangle)
    CG1 = Atom("CG1", carbon_g1, 0.0, 1.0, " ", " CG1", 0, "C")
    carbon_g2 = calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle,
                                     N_CA_CB_CG2_diangle)
    CG2 = Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C")
    carbon_d1 = calculateCoordinates(CA, CB, CG1, CG1_CD1_length,
                                     CB_CG1_CD1_angle, CA_CB_CG1_CD1_diangle)
    CD1 = Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C")

    ##Create Residue Data Structure
    res = Residue((" ", segID, " "), "ILE", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG1)
    res.add(CG2)
    res.add(CD1)
    return res
Exemplo n.º 27
0
def makeAsn(segID, N, CA, C, O, geo):
    """Creates an Asparagine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_CG_length = geo.CB_CG_length
    CA_CB_CG_angle = geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle = geo.N_CA_CB_CG_diangle

    CG_OD1_length = geo.CG_OD1_length
    CB_CG_OD1_angle = geo.CB_CG_OD1_angle
    CA_CB_CG_OD1_diangle = geo.CA_CB_CG_OD1_diangle

    CG_ND2_length = geo.CG_ND2_length
    CB_CG_ND2_angle = geo.CB_CG_ND2_angle
    CA_CB_CG_ND2_diangle = geo.CA_CB_CG_ND2_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    carbon_g = calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle,
                                    N_CA_CB_CG_diangle)
    CG = Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    oxygen_d1 = calculateCoordinates(CA, CB, CG, CG_OD1_length,
                                     CB_CG_OD1_angle, CA_CB_CG_OD1_diangle)
    OD1 = Atom("OD1", oxygen_d1, 0.0, 1.0, " ", " OD1", 0, "O")
    nitrogen_d2 = calculateCoordinates(CA, CB, CG, CG_ND2_length,
                                       CB_CG_ND2_angle, CA_CB_CG_ND2_diangle)
    ND2 = Atom("ND2", nitrogen_d2, 0.0, 1.0, " ", " ND2", 0, "N")
    res = Residue((" ", segID, " "), "ASN", "    ")

    ##Create Residue Data Structure
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(OD1)
    res.add(ND2)
    return res
Exemplo n.º 28
0
def makeMet(segID: int, N, CA, C, O, geo: MetGeo) -> Residue:
    """Creates a Methionine residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_CG_length = geo.CB_CG_length
    CA_CB_CG_angle = geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle = geo.N_CA_CB_CG_diangle

    CG_SD_length = geo.CG_SD_length
    CB_CG_SD_angle = geo.CB_CG_SD_angle
    CA_CB_CG_SD_diangle = geo.CA_CB_CG_SD_diangle

    SD_CE_length = geo.SD_CE_length
    CG_SD_CE_angle = geo.CG_SD_CE_angle
    CB_CG_SD_CE_diangle = geo.CB_CG_SD_CE_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    carbon_g = calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle,
                                    N_CA_CB_CG_diangle)
    CG = Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    sulfur_d = calculateCoordinates(CA, CB, CG, CG_SD_length, CB_CG_SD_angle,
                                    CA_CB_CG_SD_diangle)
    SD = Atom("SD", sulfur_d, 0.0, 1.0, " ", " SD", 0, "S")
    carbon_e = calculateCoordinates(CB, CG, SD, SD_CE_length, CG_SD_CE_angle,
                                    CB_CG_SD_CE_diangle)
    CE = Atom("CE", carbon_e, 0.0, 1.0, " ", " CE", 0, "C")

    ##Create Residue Data Structure
    res = Residue((" ", segID, " "), "MET", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(SD)
    res.add(CE)
    return res
Exemplo n.º 29
0
    def __init__(self, pdbfile):
        self.chains = []
        self.cg_atoms = []  # C4' | P | N1 / N9 ==> changed in mass_center
        self.atoms_triads = []  # according to cg_triads dictionary
        self.pdb_residues = []
        self.coords = []
        self.changed_coords = False

        p = PDBParser()
        if len(pdbfile.split('/')) > 1:
            self.name = pdbfile.split('/')[-1]
        self.name = self.name.split('.')[0]
        print(pdbfile)

        chains = []
        self.structure = p.get_structure(self.name, pdbfile)
        for chain in self.structure[0]:  # model_1
            ch = RNAChain(chain.id)
            chains.append(ch)
            for residue in chain.get_residues():
                res = Residue(residue.get_resname())
                cg_atoms_list = []
                atoms_pdb = []
                for atom in residue:
                    coords = list(atom.get_vector())
                    res.add_atom(
                        Atom(Vector3d(coords[0], coords[1], coords[2]),
                             atom.id, atom.mass))
                    if residue.get_resname() in ['  A', '  G'
                                                 ] and atom.id in cg_atoms_pur:
                        cg_atoms_list.append(atom)
                    if residue.get_resname() in ['  C', '  U'
                                                 ] and atom.id in cg_atoms_pir:
                        cg_atoms_list.append(atom)
                    if residue.get_resname() in cg_tiads.keys(
                    ) and atom.id in cg_tiads[residue.get_resname()]:
                        atoms_pdb.append(atom)
                if res.atoms != [] and len(cg_atoms_list) == 3 and len(
                        atoms_pdb) == 5:
                    ch.add_residue(res)
                    for at in atoms_pdb:
                        self.atoms_triads.append(at)
                    self.pdb_residues.append(residue)
                    for at in cg_atoms_list:
                        self.cg_atoms.append(at)

        for chain in chains:
            if len(chain.residues) >= 1:
                self.chains.append(chain)

        self.atoms = []  #MAIN CHAIN
        for atom in self.get_atoms():
            if atom.kind in ["C4'", "P"]:
                self.atoms.append(atom)
        self.cg_atoms_all = self.get_atoms()
Exemplo n.º 30
0
def makeAsp(segID: int, N, CA, C, O, geo: AspGeo) -> Residue:
    """Creates an Aspartic Acid residue"""
    ##R-Group
    CA_CB_length = geo.CA_CB_length
    C_CA_CB_angle = geo.C_CA_CB_angle
    N_C_CA_CB_diangle = geo.N_C_CA_CB_diangle

    CB_CG_length = geo.CB_CG_length
    CA_CB_CG_angle = geo.CA_CB_CG_angle
    N_CA_CB_CG_diangle = geo.N_CA_CB_CG_diangle

    CG_OD1_length = geo.CG_OD1_length
    CB_CG_OD1_angle = geo.CB_CG_OD1_angle
    CA_CB_CG_OD1_diangle = geo.CA_CB_CG_OD1_diangle

    CG_OD2_length = geo.CG_OD2_length
    CB_CG_OD2_angle = geo.CB_CG_OD2_angle
    CA_CB_CG_OD2_diangle = geo.CA_CB_CG_OD2_diangle

    carbon_b = calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle,
                                    N_C_CA_CB_diangle)
    CB = Atom("CB", carbon_b, 0.0, 1.0, " ", " CB", 0, "C")
    carbon_g = calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle,
                                    N_CA_CB_CG_diangle)
    CG = Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C")
    oxygen_d1 = calculateCoordinates(CA, CB, CG, CG_OD1_length,
                                     CB_CG_OD1_angle, CA_CB_CG_OD1_diangle)
    OD1 = Atom("OD1", oxygen_d1, 0.0, 1.0, " ", " OD1", 0, "O")
    oxygen_d2 = calculateCoordinates(CA, CB, CG, CG_OD2_length,
                                     CB_CG_OD2_angle, CA_CB_CG_OD2_diangle)
    OD2 = Atom("OD2", oxygen_d2, 0.0, 1.0, " ", " OD2", 0, "O")

    res = Residue((" ", segID, " "), "ASP", "    ")
    res.add(N)
    res.add(CA)
    res.add(C)
    res.add(O)
    res.add(CB)
    res.add(CG)
    res.add(OD1)
    res.add(OD2)
    return res
Exemplo n.º 31
0
def makebiopython(atomcoords, atomnos):
    """Create a list of BioPython Atoms.

    This creates a list of BioPython Atoms suitable for use by
    Bio.PDB.Superimposer, for example.
    """
    pt = PeriodicTable()
    bioatoms = []
    for coords, atomno in zip(atomcoords, atomnos):
        symbol = pt.element[atomno]
        bioatoms.append(
            Atom(symbol, coords, 0, 0, 0, symbol, 0, symbol.upper()))
    return bioatoms
Exemplo n.º 32
0
class StructureBuilder(object):
    """Deals with contructing the Structure object.

    The StructureBuilder class is used by the PDBParser classes to
    translate a file to a Structure object.
    """

    def __init__(self):
        self.line_counter = 0
        self.header = {}

    def _is_completely_disordered(self, residue):
        """Return 1 if all atoms in the residue have a non blank altloc."""
        atom_list = residue.get_unpacked_list()
        for atom in atom_list:
            altloc = atom.get_altloc()
            if altloc == " ":
                return 0
        return 1

    # Public methods called by the Parser classes

    def set_header(self, header):
        self.header = header

    def set_line_counter(self, line_counter):
        """Tracks line in the PDB file that is being parsed.

        Arguments:
         - line_counter - int

        """
        self.line_counter = line_counter

    def init_structure(self, structure_id):
        """Initiate a new Structure object with given id.

        Arguments:
         - id - string

        """
        self.structure = Structure(structure_id)

    def init_model(self, model_id, serial_num=None):
        """Initiate a new Model object with given id.

        Arguments:
         - id - int
         - serial_num - int

        """
        self.model = Model(model_id, serial_num)
        self.structure.add(self.model)

    def init_chain(self, chain_id):
        """Initiate a new Chain object with given id.

        Arguments:
         - chain_id - string

        """
        if self.model.has_id(chain_id):
            self.chain = self.model[chain_id]
            warnings.warn("WARNING: Chain %s is discontinuous at line %i."
                          % (chain_id, self.line_counter),
                          PDBConstructionWarning)
        else:
            self.chain = Chain(chain_id)
            self.model.add(self.chain)

    def init_seg(self, segid):
        """Flag a change in segid.

        Arguments:
         - segid - string

        """
        self.segid = segid

    def init_residue(self, resname, field, resseq, icode):
        """Initiate a new Residue object.

        Arguments:
         - resname - string, e.g. "ASN"
         - field - hetero flag, "W" for waters, "H" for
           hetero residues, otherwise blank.
         - resseq - int, sequence identifier
         - icode - string, insertion code

        """
        if field != " ":
            if field == "H":
                # The hetero field consists of H_ + the residue name (e.g. H_FUC)
                field = "H_" + resname
        res_id = (field, resseq, icode)
        if field == " ":
            if self.chain.has_id(res_id):
                # There already is a residue with the id (field, resseq, icode).
                # This only makes sense in the case of a point mutation.
                warnings.warn("WARNING: Residue ('%s', %i, '%s') "
                              "redefined at line %i."
                              % (field, resseq, icode, self.line_counter),
                              PDBConstructionWarning)
                duplicate_residue = self.chain[res_id]
                if duplicate_residue.is_disordered() == 2:
                    # The residue in the chain is a DisorderedResidue object.
                    # So just add the last Residue object.
                    if duplicate_residue.disordered_has_id(resname):
                        # The residue was already made
                        self.residue = duplicate_residue
                        duplicate_residue.disordered_select(resname)
                    else:
                        # Make a new residue and add it to the already
                        # present DisorderedResidue
                        new_residue = Residue(res_id, resname, self.segid)
                        duplicate_residue.disordered_add(new_residue)
                        self.residue = duplicate_residue
                        return
                else:
                    if resname == duplicate_residue.resname:
                        warnings.warn("WARNING: Residue ('%s', %i, '%s','%s')"
                                      " already defined with the same name at line  %i."
                              % (field, resseq, icode, resname, self.line_counter),
                              PDBConstructionWarning)
                        self.residue = duplicate_residue
                        return
                    # Make a new DisorderedResidue object and put all
                    # the Residue objects with the id (field, resseq, icode) in it.
                    # These residues each should have non-blank altlocs for all their atoms.
                    # If not, the PDB file probably contains an error.
                    if not self._is_completely_disordered(duplicate_residue):
                        # if this exception is ignored, a residue will be missing
                        self.residue = None
                        raise PDBConstructionException(
                            "Blank altlocs in duplicate residue %s ('%s', %i, '%s')"
                            % (resname, field, resseq, icode))
                    self.chain.detach_child(res_id)
                    new_residue = Residue(res_id, resname, self.segid)
                    disordered_residue = DisorderedResidue(res_id)
                    self.chain.add(disordered_residue)
                    disordered_residue.disordered_add(duplicate_residue)
                    disordered_residue.disordered_add(new_residue)
                    self.residue = disordered_residue
                    return
        self.residue = Residue(res_id, resname, self.segid)
        self.chain.add(self.residue)

    def init_atom(self, name, coord, b_factor, occupancy, altloc, fullname,
                  serial_number=None, element=None):
        """Initiate a new Atom object.

        Arguments:
         - name - string, atom name, e.g. CA, spaces should be stripped
         - coord - Numeric array (Float0, size 3), atomic coordinates
         - b_factor - float, B factor
         - occupancy - float
         - altloc - string, alternative location specifier
         - fullname - string, atom name including spaces, e.g. " CA "
         - element - string, upper case, e.g. "HG" for mercury

        """
        residue = self.residue
        # if residue is None, an exception was generated during
        # the construction of the residue
        if residue is None:
            return
        # First check if this atom is already present in the residue.
        # If it is, it might be due to the fact that the two atoms have atom
        # names that differ only in spaces (e.g. "CA.." and ".CA.",
        # where the dots are spaces). If that is so, use all spaces
        # in the atom name of the current atom.
        if residue.has_id(name):
            duplicate_atom = residue[name]
            # atom name with spaces of duplicate atom
            duplicate_fullname = duplicate_atom.get_fullname()
            if duplicate_fullname != fullname:
                # name of current atom now includes spaces
                name = fullname
                warnings.warn("Atom names %r and %r differ "
                              "only in spaces at line %i."
                              % (duplicate_fullname, fullname,
                                 self.line_counter),
                              PDBConstructionWarning)
        self.atom = Atom(name, coord, b_factor, occupancy, altloc,
                         fullname, serial_number, element)
        if altloc != " ":
            # The atom is disordered
            if residue.has_id(name):
                # Residue already contains this atom
                duplicate_atom = residue[name]
                if duplicate_atom.is_disordered() == 2:
                    duplicate_atom.disordered_add(self.atom)
                else:
                    # This is an error in the PDB file:
                    # a disordered atom is found with a blank altloc
                    # Detach the duplicate atom, and put it in a
                    # DisorderedAtom object together with the current
                    # atom.
                    residue.detach_child(name)
                    disordered_atom = DisorderedAtom(name)
                    residue.add(disordered_atom)
                    disordered_atom.disordered_add(self.atom)
                    disordered_atom.disordered_add(duplicate_atom)
                    residue.flag_disordered()
                    warnings.warn("WARNING: disordered atom found "
                                  "with blank altloc before line %i.\n"
                                  % self.line_counter,
                                  PDBConstructionWarning)
            else:
                # The residue does not contain this disordered atom
                # so we create a new one.
                disordered_atom = DisorderedAtom(name)
                residue.add(disordered_atom)
                # Add the real atom to the disordered atom, and the
                # disordered atom to the residue
                disordered_atom.disordered_add(self.atom)
                residue.flag_disordered()
        else:
            # The atom is not disordered
            residue.add(self.atom)

    def set_anisou(self, anisou_array):
        """Set anisotropic B factor of current Atom."""
        self.atom.set_anisou(anisou_array)

    def set_siguij(self, siguij_array):
        """Set standard deviation of anisotropic B factor of current Atom."""
        self.atom.set_siguij(siguij_array)

    def set_sigatm(self, sigatm_array):
        """Set standard deviation of atom position of current Atom."""
        self.atom.set_sigatm(sigatm_array)

    def get_structure(self):
        """Return the structure."""
        # first sort everything
        # self.structure.sort()
        # Add the header dict
        self.structure.header = self.header
        return self.structure

    def set_symmetry(self, spacegroup, cell):
        pass
Exemplo n.º 33
0
    def init_atom(self, name, coord, b_factor, occupancy, altloc, fullname,
                  serial_number=None, element=None):
        """Initiate a new Atom object.

        Arguments:
         - name - string, atom name, e.g. CA, spaces should be stripped
         - coord - Numeric array (Float0, size 3), atomic coordinates
         - b_factor - float, B factor
         - occupancy - float
         - altloc - string, alternative location specifier
         - fullname - string, atom name including spaces, e.g. " CA "
         - element - string, upper case, e.g. "HG" for mercury

        """
        residue = self.residue
        # if residue is None, an exception was generated during
        # the construction of the residue
        if residue is None:
            return
        # First check if this atom is already present in the residue.
        # If it is, it might be due to the fact that the two atoms have atom
        # names that differ only in spaces (e.g. "CA.." and ".CA.",
        # where the dots are spaces). If that is so, use all spaces
        # in the atom name of the current atom.
        if residue.has_id(name):
            duplicate_atom = residue[name]
            # atom name with spaces of duplicate atom
            duplicate_fullname = duplicate_atom.get_fullname()
            if duplicate_fullname != fullname:
                # name of current atom now includes spaces
                name = fullname
                warnings.warn("Atom names %r and %r differ "
                              "only in spaces at line %i."
                              % (duplicate_fullname, fullname,
                                 self.line_counter),
                              PDBConstructionWarning)
        self.atom = Atom(name, coord, b_factor, occupancy, altloc,
                         fullname, serial_number, element)
        if altloc != " ":
            # The atom is disordered
            if residue.has_id(name):
                # Residue already contains this atom
                duplicate_atom = residue[name]
                if duplicate_atom.is_disordered() == 2:
                    duplicate_atom.disordered_add(self.atom)
                else:
                    # This is an error in the PDB file:
                    # a disordered atom is found with a blank altloc
                    # Detach the duplicate atom, and put it in a
                    # DisorderedAtom object together with the current
                    # atom.
                    residue.detach_child(name)
                    disordered_atom = DisorderedAtom(name)
                    residue.add(disordered_atom)
                    disordered_atom.disordered_add(self.atom)
                    disordered_atom.disordered_add(duplicate_atom)
                    residue.flag_disordered()
                    warnings.warn("WARNING: disordered atom found "
                                  "with blank altloc before line %i.\n"
                                  % self.line_counter,
                                  PDBConstructionWarning)
            else:
                # The residue does not contain this disordered atom
                # so we create a new one.
                disordered_atom = DisorderedAtom(name)
                residue.add(disordered_atom)
                # Add the real atom to the disordered atom, and the
                # disordered atom to the residue
                disordered_atom.disordered_add(self.atom)
                residue.flag_disordered()
        else:
            # The atom is not disordered
            residue.add(self.atom)