def __init__(self, chainlines, parent): Polymer.__init__(self, chainlines, parent) # store a list element for each nucleotide in chainlines last_line = None current_residue = [] atoms = [] atom_cnt = 0 for line in chainlines: current_line = line[25:29] if current_line == last_line: # just append to the previously created one current_residue.append(line) atoms.append(self.atoms[atom_cnt]) else: # make a new amino acid and append it to residues list if len(current_residue) > 0: new_residue = Nucleotide(current_residue, self, atoms) self.add_residue(new_residue) # reset the current list and append the new line to it current_residue = [] current_residue.append(line) atoms = [] atoms.append(self.atoms[atom_cnt]) last_line = current_line atom_cnt = atom_cnt + 1 # append the last one created new_residue = Nucleotide(current_residue, self, atoms) self.add_residue(new_residue) self.locate_termini() self.residues_dict = {} for res in self.residues: self.residues_dict['%s' % (res.res_number)] = res
def __init__(self, chainlines, parent): Polymer.__init__(self,chainlines, parent) # store a list element for each nucleotide in chainlines last_line = None current_residue = [] atoms = [] atom_cnt = 0 for line in chainlines: current_line = line[25:29] if current_line == last_line: # just append to the previously created one current_residue.append(line) atoms.append(self.atoms[atom_cnt]) else: # make a new amino acid and append it to residues list if len(current_residue)>0: new_residue = Nucleotide(current_residue, self, atoms) self.add_residue(new_residue) # reset the current list and append the new line to it current_residue = [] current_residue.append(line) atoms = [] atoms.append(self.atoms[atom_cnt]) last_line = current_line atom_cnt = atom_cnt + 1 # append the last one created new_residue = Nucleotide(current_residue, self, atoms) self.add_residue(new_residue) self.locate_termini() self.residues_dict = {} for res in self.residues: self.residues_dict['%s'%(res.res_number)] = res
def __init__(self, PDBlines, parent): self.atomsHydList=[] Polymer.__init__(self,PDBlines, parent) # store a list element for each amino acid in PDBlines last_line = None current_residue = [] atoms = [] atom_cnt = 0 offset = 0 min_lengths = {'ALA':5, 'CYS':6, 'ASP':8, 'GLU':9, 'PHE':11, 'GLY':4, 'HIS':10, 'ILE':8, 'LYS':9, 'LEU':8, 'MET':8, 'ASN':8, 'PRO':7, 'GLN':9, 'ARG':11, 'SER':6, 'THR':7, 'VAL':7, 'TRP':14, 'TYR':12} for line in PDBlines: current_line = line[25:29] if current_line == last_line: # handle duplicate atom records atomname = line[12:16] splitname = string.split(string.strip(atomname)) if len(splitname) == 2: # have a 'CA A' or some such thing if splitname[1] != 'A': # dismiss B or C duplicates last_line = current_line atom_cnt += 1 continue else: line = line[:15] + ' ' + line[16:] # just get rid of the 'A' self.atoms[atom_cnt].atom_type = string.split(self.atoms[atom_cnt].atom_type)[0] else: # if the line has a number, followed by a letter, it must be duplicate if line[14] in ['1','2','3','4'] and line[15] in ['A','B','C','D']: if line[15] in ['B','C','D']: # get rid of the Bs Cs and Ds last_line = current_line atom_cnt += 1 continue else: line = line[:15] + ' ' + line[16:] self.atoms[atom_cnt].atom_type = self.atoms[atom_cnt].atom_type[:-1] # just append to the previously created one current_residue.append(line) atoms.append(self.atoms[atom_cnt]) else: # make a new amino acid and append it to residues list if len(current_residue)>0: if len(current_residue) >= min_lengths[current_residue[0][17:20]]: new_residue = AminoAcid(self, current_residue, atoms) self.add_residue(new_residue) # reset the current list and append the new line to it current_residue = [] atoms = [] current_residue.append(line) atoms.append(self.atoms[atom_cnt]) last_line = current_line atom_cnt += 1 # append the last one created if len(current_residue) >= min_lengths[current_residue[0][17:20]]: new_residue = AminoAcid(self, current_residue, atoms) self.add_residue(new_residue) # this initializes proteolysis type, so that the chain knows if a calculation has been done self.proteolysis_type = 'none' self.locate_termini() self.residues_dict = {} for res in self.residues: self.residues_dict['%s'%(res.res_number)] = res