Commit 73d44e48 authored by Fabrice  ALLAIN's avatar Fabrice ALLAIN

fix: avoid empty violation files if there is substitutions in the reference file

parent b8641524
......@@ -416,10 +416,12 @@ class EnsembleAnalysis(object):
natsegids = set([r.get_segid() for r in native.get_residues()])
natseqs = [r.get_resname() for r in native.get_residues()
if r.get_id()[0] == ' ']
cmpseqs = [molseqs[idx] == natseqs[idx]
for idx in range(0, min(len(molseqs), len(natseqs))-1)]
# cmpseqs = [molseqs[idx] == natseqs[idx]
# for idx in range(0, min(len(molseqs), len(natseqs))-1)]
if natsegids != molsegids and False not in cmpseqs:
# TODO: Doesn't work if there is substitutions in the reference file
# if natsegids != molsegids and False not in cmpseqs:
if natsegids != molsegids:
if len(natsegids) == len(molsegids) == 1:
parser.structure_builder.init_seg(list(molsegids)[0])
native = parser.get_structure(protein_id, native_path)
......
......@@ -328,12 +328,9 @@ class AriaXMLConverter(Converter, object):
"""
xml_file = open(outfile, "w")
xml_file.write('''\
<!DOCTYPE distance_restraint_list SYSTEM "distance_restraint1.0.dtd">
<distance_restraint_list>
''')
# Pour chaque contrainte
# Pour chaque contribution
xml_content = ""
for restraint_id in dist_restraints:
restraint = {
'rest_id': restraint_id,
......@@ -347,12 +344,12 @@ class AriaXMLConverter(Converter, object):
'reliable': dist_restraints[restraint_id]["meta"]["reliable"],
'list_name': dist_restraints[restraint_id]["meta"]["list_name"]
}
xml_file.write('''\
xml_content += '''\
<restraint id="{rest_id}" weight="{rest_weight:.1f}" \
distance="{rest_dist:.1f}" lower_bound="{lower_bound:.1f}"\
upper_bound="{upper_bound:.1f}" active="1" \
reliable="{reliable}" list_name="{list_name}">
'''.format(**restraint))
'''.format(**restraint)
for contrib_id in dist_restraints[restraint_id]["contrib"]:
res_id = dist_restraints[restraint_id]["contrib"][contrib_id][
"spin_pair"].keys()
......@@ -361,27 +358,29 @@ reliable="{reliable}" list_name="{list_name}">
"meta"].get("segids")
segid1 = segids[res_id[0]] if segids else " A"
segid2 = segids[res_id[1]] if segids else " A"
xml_file.write('''\
xml_content += '''\
<contribution id="{id}" weight="{weight:.8f}">
<spin_pair>
<atom segid="{res1_segid}" residue="{res1_pos}" name="{atm1_name}"/>
<atom segid="{res2_segid}" residue="{res2_pos}" name="{atm2_name}"/>
</spin_pair>
</contribution>
'''.format(id=contrib_id, res1_segid=segid1, res2_segid=segid2,
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]]))
xml_file.write('''\
'''.format(
id=contrib_id, res1_segid=segid1, res2_segid=segid2,
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]])
xml_content += '''\
</restraint>
''')
xml_file.write('''\
'''
if xml_content:
xml_file.write('''\
<!DOCTYPE distance_restraint_list SYSTEM "distance_restraint1.0.dtd">
<distance_restraint_list>
{xml_content}
</distance_restraint_list>
''')
'''.format(xml_content=xml_content))
@staticmethod
def _write_helix_hb_tbl(sec_struct, outfile, dminus, dplus):
......@@ -1716,9 +1715,12 @@ class AriaEcXMLConverter(AriaXMLConverter):
convtable = ConversionTable()
xml_paths = []
list_name = MapFile.conkit_alias[list_name] \
if list_name in MapFile.conkit_alias else list_name
# Read tbl file(s) and build dist_restraints dict
for tbl_path in tbl_paths:
LOG.info("Read TBL file %s", tbl_path)
tbl = TblDistFile(tbl_path)
tbl.load()
xml_path = os.path.join(
......@@ -1799,12 +1801,12 @@ class AriaEcXMLConverter(AriaXMLConverter):
LOG.info("Wrote %d xml distance restraints in %s",
len(xmldists),
xml_path)
AriaXMLConverter.write_dist_xml(xmldists, xml_path)
xml_paths.append(xml_path)
else:
LOG.info("No distance restraints found in %s. %s will be empty",
tbl_path, xml_path)
open(xml_path, 'a').close()
AriaXMLConverter.write_dist_xml(xmldists, xml_path)
return xml_paths
......@@ -1815,8 +1817,6 @@ class AriaEcXMLConverter(AriaXMLConverter):
molecule_path = self.settings.tbl2xml.args["molecule"]
tbl_paths = self.settings.tbl2xml.args["infiles"]
list_name = self.settings.tbl2xml.args["listname"]
list_name = MapFile.conkit_alias[list_name] \
if list_name in MapFile.conkit_alias else list_name
self.tbl2xml(outdir_path, molecule_path, tbl_paths, list_name)
......
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