Aglaé TABOT

management of special cases

Showing 1 changed file with 15 additions and 6 deletions
...@@ -159,14 +159,14 @@ class SelectivePortionSelector(object): ...@@ -159,14 +159,14 @@ class SelectivePortionSelector(object):
159 _select=Select() 159 _select=Select()
160 160
161 def save_mmcif(ioobj, out_file, select=_select, preserve_atom_numbering=False): 161 def save_mmcif(ioobj, out_file, select=_select, preserve_atom_numbering=False):
162 + # reuse and modification of the source code of Biopython
163 + # to have the 2 columns of numbering of residues numbered with the index_chain of DSSR
162 if isinstance(out_file, str): 164 if isinstance(out_file, str):
163 fp = open(out_file, "w") 165 fp = open(out_file, "w")
164 close_file = True 166 close_file = True
165 else: 167 else:
166 fp = out_file 168 fp = out_file
167 close_file = False 169 close_file = False
168 - #fp = open(out_file, "w")
169 - #close_file=True
170 atom_dict = defaultdict(list) 170 atom_dict = defaultdict(list)
171 171
172 for model in ioobj.structure.get_list(): 172 for model in ioobj.structure.get_list():
...@@ -188,7 +188,7 @@ def save_mmcif(ioobj, out_file, select=_select, preserve_atom_numbering=False): ...@@ -188,7 +188,7 @@ def save_mmcif(ioobj, out_file, select=_select, preserve_atom_numbering=False):
188 chain_id = chain.get_id() 188 chain_id = chain.get_id()
189 if chain_id == " ": 189 if chain_id == " ":
190 chain_id = "." 190 chain_id = "."
191 - # This is used to write label_seq_id and increments from 1, 191 + # This is used to write label_seq_id,
192 # remaining blank for hetero residues 192 # remaining blank for hetero residues
193 193
194 prev_residue_type = "" 194 prev_residue_type = ""
...@@ -403,8 +403,9 @@ class Chain: ...@@ -403,8 +403,9 @@ class Chain:
403 resseq=int(resseq) 403 resseq=int(resseq)
404 index_chain=nums.at[i, "index_chain"] 404 index_chain=nums.at[i, "index_chain"]
405 nt=nums.at[i, "nt_name"] 405 nt=nums.at[i, "nt_name"]
406 - 406 +
407 - if nt == 'A' or nt == 'G' or nt == 'C' or nt == 'U' or nt in ['DG', 'DU', 'DC', 'DA', 'DI', 'DT' ] or nt == 'N' or nt == 'I' : 407 + # particular case 6n5s_1_A, residue 201 in the original cif file (resname = G and HETATM = H_G)
408 + if nt == 'A' or (nt == 'G' and (self.chain_label != '6n5s_1_A' and resseq != 201)) or nt == 'C' or nt == 'U' or nt in ['DG', 'DU', 'DC', 'DA', 'DI', 'DT' ] or nt == 'N' or nt == 'I' :
408 res=chain[(' ', resseq, icode_res)] 409 res=chain[(' ', resseq, icode_res)]
409 else : #modified nucleotides (e.g. chain 5l4o_1_A) 410 else : #modified nucleotides (e.g. chain 5l4o_1_A)
410 het='H_' + nt 411 het='H_' + nt
...@@ -422,7 +423,15 @@ class Chain: ...@@ -422,7 +423,15 @@ class Chain:
422 res_atoms=res.get_atoms() 423 res_atoms=res.get_atoms()
423 new_residu_t=pdb.Residue.Residue(res_id, res_name, res.get_segid()) 424 new_residu_t=pdb.Residue.Residue(res_id, res_name, res.get_segid())
424 for atom in list(res.get_atoms()): 425 for atom in list(res.get_atoms()):
425 - if atom.get_name() in ['PA', 'O1A', 'O2A', 'O3A']: 426 + # rename the remaining phosphate group to P, OP1, OP2, OP3
427 + if atom.get_name() in ['PA', 'O1A', 'O2A', 'O3A'] and res_name != 'RIA':
428 +
429 + # RIA is a residue made up of 2 riboses and 2 phosphates,
430 + # so it has an O2A atom between the C2A and C1 'atoms,
431 + # and it also has an OP2 atom attached to one of its phosphates
432 + # (see chains 6fyx_1_1, 6zu9_1_1, 6fyy_1_1, 6gsm_1_1 , 3jaq_1_1 and 1yfg_1_A)
433 + # we do not modify the atom names of RIA residue
434 +
426 if atom.get_name() == 'PA': 435 if atom.get_name() == 'PA':
427 atom_name = 'P' 436 atom_name = 'P'
428 if atom.get_name() == 'O1A': 437 if atom.get_name() == 'O1A':
......