Commit 2a12b7ef authored by Fabrice  ALLAIN's avatar Fabrice ALLAIN

fix(conbox): add checks for atoms during restraints conversion

parent 3ce8b56a
......@@ -235,12 +235,12 @@ class AriaXMLConverter(Converter, object):
chain_types[segid] = self._mol_set['type']
self._sequence = SequenceList(chain_types,
self._mol_set['first_residue_number'])
self._mol_set['first_residue_number'])
# with Capturing() as output:
# Initialize SequenceList object with seq file
self._sequence.parse(self._mol_set['input'], self._mol_set['format'],
self._mol_set['naming_convention'])
self._mol_set['naming_convention'])
# LOG.info("\n" + "".join(output))
......@@ -367,10 +367,15 @@ reliable="{reliable}" list_name="{list_name}">
</contribution>
'''.format(
id=contrib_id, res1_segid=segid1, res2_segid=segid2,
weight=dist_restraints[restraint_id]["contrib"][contrib_id]["meta"]["weight"],
weight=dist_restraints[restraint_id]["contrib"][contrib_id][
"meta"]["weight"],
res1_pos=res_id[0], res2_pos=res_id[1],
atm1_name=dist_restraints[restraint_id]["contrib"][contrib_id]["spin_pair"][res_id[0]],
atm2_name=dist_restraints[restraint_id]["contrib"][contrib_id]["spin_pair"][res_id[1]])
atm1_name=
dist_restraints[restraint_id]["contrib"][contrib_id][
"spin_pair"][res_id[0]],
atm2_name=
dist_restraints[restraint_id]["contrib"][contrib_id][
"spin_pair"][res_id[1]])
xml_content += '''\
</restraint>
'''
......@@ -404,7 +409,7 @@ reliable="{reliable}" list_name="{list_name}">
"""
outfile.write("! Short range Hbond list (Alpha helix)")
n=0
n = 0
for idx, secstr in enumerate(sec_struct):
if (idx + 4) < len(sec_struct):
if 'H' in secstr[2] and 'H' in sec_struct[idx + 4][2]:
......@@ -584,7 +589,8 @@ assign (resid {res1} and name o) (resid {res2} and name hn) 1.8 {dminus} {dplus
res2 = resid2 + 1
outfile.write('''\
assign (resid {res1} and name {atm1}) (resid {res2} and name {atm2}) {dist} {sdev} {sdev} weight {weight} !spec=ssdist
'''.format(res1=res1, atm1=atm1, res2=res2, atm2=atm2, dist=dist, sdev=sdev, weight=weight))
'''.format(res1=res1, atm1=atm1, res2=res2, atm2=atm2, dist=dist, sdev=sdev,
weight=weight))
@staticmethod
def write_dihedral_tbl(secstructs, outfile, knrj=0.5, exp=2):
......@@ -639,6 +645,7 @@ assign (resid {res1} and name n) (resid {res1} and name ca) (resid {res1} and na
class AriaEcXMLConverter(AriaXMLConverter):
"""XML converter ariaec to aria"""
# TODO: use aria api instead to generate xml files
def __init__(self, *args, **kwargs):
self.restraint_list = []
......@@ -859,6 +866,7 @@ class AriaEcXMLConverter(AriaXMLConverter):
"""
def resname(res):
"""
......@@ -886,8 +894,8 @@ class AriaEcXMLConverter(AriaXMLConverter):
((idx1, atm1), (idx2, atm2)) for (atm1, atm2) in
list(itertools.product(atms1, atms2))
if atm1 == atm2 or (
atm1 not in ('CA', 'CB')
and atm2 not in ('CA', 'CB')
atm1 not in ('CA', 'CB')
and atm2 not in ('CA', 'CB')
) or (atm1, atm2) == self.settings.scsc_min[
resname(res1)][resname(res2)]], ] if list_type == 'min' \
else [[(atm1, atm2) for (atm1, atm2) in
......@@ -915,9 +923,10 @@ class AriaEcXMLConverter(AriaXMLConverter):
((idx1, atm1), (idx2, atm2)) for (atm1, atm2) in
list(itertools.product(atms1, atms2))
if atm1 == atm2 or (
atm1 not in ('CA', 'CB')
and atm2 not in (
'CA', 'CB')) or (atm1, atm2) == self.settings.scsc_min[
atm1 not in ('CA', 'CB')
and atm2 not in (
'CA', 'CB')) or (atm1, atm2) ==
self.settings.scsc_min[
resname(res1)][
resname(res2)]] if list_type == 'min' else [
(atm1, atm2) for (atm1, atm2) in
......@@ -1159,7 +1168,7 @@ class AriaEcXMLConverter(AriaXMLConverter):
dist_list = []
if type(distmap) == ResAtmMap and \
distmap.sequence == protein.aa_sequence.sequence:
distmap.sequence == protein.aa_sequence.sequence:
for contrib in contribs:
mapidx_x = distmap.index.levels[0][contrib[0][0]]
mapidx_y = distmap.index.levels[0][contrib[1][0]]
......@@ -1213,7 +1222,7 @@ class AriaEcXMLConverter(AriaXMLConverter):
else:
dist_list.append(defaultdist)
elif type(distmap) == ResMap and \
distmap.sequence == protein.aa_sequence.sequence:
distmap.sequence == protein.aa_sequence.sequence:
for contrib in contribs:
dist_list.append("%.2f" % distmap.iat[
contrib[0][0], contrib[1][0]])
......@@ -1475,7 +1484,7 @@ class AriaEcXMLConverter(AriaXMLConverter):
"""
# Setting contact number limit for hbmap
n_hb = int(len(self.sequence.bases) *
self.settings.setup.config.get("nf_longrange_hb"))
self.settings.setup.config.get("nf_longrange_hb"))
dihed_file = os.path.join(self.settings.infra["tbl"], self.outprefix +
"_dihed.tbl")
hb_file = os.path.join(self.settings.infra["tbl"], self.outprefix +
......@@ -1490,8 +1499,9 @@ class AriaEcXMLConverter(AriaXMLConverter):
ssdist_file)
self.write_ssdist_tbl(protein.sec_struct.ss_matrix,
protein.sec_struct.ssdist,
ssdist_file,
weight=self.settings.setup.config['ss_weight'])
ssdist_file,
weight=self.settings.setup.config[
'ss_weight'])
LOG.info(" Helix bond restraints (%s)", hb_file)
self.write_hb_tbl(protein, hb_file,
hbmap=hbmap, n_hb=n_hb,
......@@ -1509,7 +1519,7 @@ class AriaEcXMLConverter(AriaXMLConverter):
#
def tbl_as_xml(self, xmlseq_file, tbl_files, list_name):
outdir_path = self.settings.infra["xml"]
outdir_path = self.settings.infra["xml"]
xml_files = self.tbl2xml(outdir_path, xmlseq_file, tbl_files, list_name)
return xml_files
......@@ -1762,15 +1772,20 @@ class AriaEcXMLConverter(AriaXMLConverter):
# ARIA XML distance restraints follow iupac names
try:
atm1_name = convtable.convert_atom(
res1.getType(), line.get("atm1").upper(), 'cns', 'iupac',
'AMINO_ACID', raise_error = 0)
res1.getType(), line.get("atm1").upper(), 'cns',
'iupac',
'AMINO_ACID', raise_error=0)
atm2_name = convtable.convert_atom(
res2.getType(), line.get("atm2").upper(), 'cns', 'iupac',
'AMINO_ACID', raise_error = 0)
res2.getType(), line.get("atm2").upper(), 'cns',
'iupac',
'AMINO_ACID', raise_error=0)
except:
atm1_name = atm2_name = None
if not res1.hasAtom(atm1_name) or res2.hasAtom(atm2_name):
continue
if not atm1_name or not atm2_name:
continue
......@@ -1779,7 +1794,7 @@ class AriaEcXMLConverter(AriaXMLConverter):
listflag = False
restno = line.get("restno")
if restno is None:
restno=len(xmldists)+1
restno = len(xmldists) + 1
restlistname = line.get("listname")
if list_name.lower() == restlistname.lower():
listflag = True
......
......@@ -53,11 +53,11 @@ class AriaEcPdbqual(CommandProtocol):
os.path.join(self.settings.pdbqual["output_directory"],
FILENAME_REPORT))
LOG.info("Removing infile(s) in output directory %s", self.settings.pdbqual["output_directory"])
[os.remove(
os.path.join(self.settings.pdbqual["output_directory"],
os.path.basename(infile)))
for infile in self.settings.pdbqual["infiles"]
if os.path.exists(os.path.join(
self.settings.pdbqual["output_directory"],
os.path.basename(infile)))
]
# [os.remove(
# os.path.join(self.settings.pdbqual["output_directory"],
# os.path.basename(infile)))
# for infile in self.settings.pdbqual["infiles"]
# if os.path.exists(os.path.join(
# self.settings.pdbqual["output_directory"],
# os.path.basename(infile)))
# ]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment