Commit 74b5ef68 authored by Fabrice  ALLAIN's avatar Fabrice ALLAIN
Browse files

Conkit reader now supported in conbox.reader. Close #4

parent 71905c34
......@@ -1542,29 +1542,17 @@ class AriaEcXMLConverter(AriaXMLConverter):
aria_project_dict = {}
# Check if ratio cool1 / cool2 is 5:4 ... (relevant ?)
# steps_1 = float(self.settings.setup.config['md_parameters_steps_cool1'])
# steps_2 = float(self.settings.setup.config['md_parameters_steps_cool2'])
# if steps_1 / steps_2 != float(5) / int(4):
# sys.exit(
# 'Length of first and second cooling stages must be fixed in '
# 'the ratio %.2f:%.2f' % (steps_1, steps_2))
aria_project_dict.update(self.settings.setup.config)
work_dir = os.path.abspath(self.settings.outdir)
temp_dir = os.path.join(os.path.abspath(aria_project_dict['temp_root']),
molecule, "_".join(datas))
if not os.path.exists(work_dir):
LOG.info("Working dir %s doesn't exist.", work_dir)
LOG.info("Create new directory %s", work_dir)
os.makedirs(work_dir)
if not os.path.exists(temp_dir):
LOG.info("Temp directory %s doesn't exist.", temp_dir)
LOG.info("Create new directory %s", temp_dir)
os.makedirs(temp_dir)
for dir_path in (work_dir, temp_dir):
if not os.path.exists(dir_path):
LOG.info("Directory %s doesn't exist.", dir_path)
LOG.info("Create new directory %s", dir_path)
os.makedirs(dir_path)
aria_project_dict['working_directory'] = work_dir
aria_project_dict['temp_root'] = temp_dir
......
......@@ -2383,7 +2383,7 @@ class MapFilter(object):
mapfilters = [elm for elm in mapfilters if elm in self.filter_types]
else:
mapfilters = [mapfilters]
if "pos" not in mapfilters:
if "pos" not in mapfilters and mtype != "bbcontacts":
mapfilters.insert(0, "pos")
if mapfilters:
LOG.info("Filtering %s contact map", mtype)
......
......@@ -11,8 +11,11 @@ import os.path
import collections
import pkg_resources as pkgr
import scipy.spatial.distance as distance
from conkit import io as conio
from Bio import pairwise2
from conkit import io as conio
from conkit.core.sequence import Sequence
from conkit.core.contactfile import ContactFile
from conkit.core.sequencefile import SequenceFile
from .common import sort_2dict
from .protmap import (ResMap, ResAtmMap)
......@@ -267,7 +270,7 @@ class MapFile(RegexFile):
"metapsicovhb": {
"regex": re.compile(
r'^\s*(?P<res_donor>\d+)[\s,;]+'
r'(?P<res_acceptor>\d+)[\s,;]+\d[\s,;]+'
r'(?P<res_acceptor>\d+)[\s,;]+(?P<dist_bound>\d)[\s,;]+'
r'(?P<res_dist>-?\d+.?\d*)[\s,;]+'
r'(?P<hbscore>-?\d+\.?\d*)'),
"score_field": "hbscore"
......@@ -425,8 +428,9 @@ class MapFile(RegexFile):
def load(self, *args):
super(MapFile, self).load(*args)
def conioload(self, *args):
"""
def conioload(self, protein):
"""Conkit loader
Use conkit io parser to load the entire file data
Returns
......@@ -435,6 +439,34 @@ class MapFile(RegexFile):
"""
with open(self.filepath) as f_in:
hierarchy = conio.read(f_in, self.filetype)
if isinstance(hierarchy, ContactFile):
conmap = hierarchy.top_map
# TODO: uniformize both packages later
# TODO: alignment aa sequence with the one assigned to the
# conmap
# TODO: check for unassigned contacts
conmap.sequence = Sequence("sequence_id",
protein.aa_sequence.sequence)
conmap.assign_sequence_register()
for contact in conmap:
conkeys = tuple(sorted([contact.res1_seq,
contact.res2_seq]))
self.contactlist.append(conkeys)
self.scorelist.append(contact.raw_score)
self.distlist.append(contact.distance_bound[1])
# TODO: use ContactMap object instead of contactlist
self.contactlist = [contact
for idx, contact in
enumerate(self.contactlist)]
self.clashlist = []
LOG.debug("New contact list (%d contacts)\n%s",
len(self.contactlist), self.contactlist)
elif isinstance(hierarchy, SequenceFile):
raise NotImplementedError("SequenceFile instance not yet "
"supported")
else:
raise IOError("Instance file not recognized")
def read(self, protein, contactdef=5.0, groupby_method="min",
scsc=None):
......@@ -460,12 +492,13 @@ class MapFile(RegexFile):
# filetype flag should only be defined when we don't use conkit for
# the reading process
LOG.info("Reading %s file", self.filepath)
# Both should fill self.lines attribute ?
if self.conioflag:
self.conioload(protein)
else:
# Read file with regex related to filetype
self.load(protein)
LOG.debug(self.lines)
LOG.debug(self.lines)
self.create_map(protein, contactdef,
groupby_method=groupby_method, scsc=scsc,
......
Supports Markdown
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