Commit 8f850252 authored by fabrice's avatar fabrice
Browse files

Changed infra call;New infra functions (ariaecsettings);infra for contactmap section

parent cbd0b94a
......@@ -186,7 +186,7 @@ class AriaEcCommand:
def create_settings(self):
logger.debug("Create AriaEcSettings")
settings = AriaEcSettings()
settings = AriaEcSettings(self.args.command)
logger.info("Loading default config file")
settings.load_config(self.default_confile, pkg=True)
if self.args.conf_file:
......@@ -198,6 +198,7 @@ class AriaEcCommand:
if self.args.output_directory:
logger.info("Updating output directory")
settings.infra = self.args.output_directory
settings.make_infra()
return settings
def run(self):
......
No preview for this file type
......@@ -47,10 +47,8 @@ pair_list: min
ambiguous_distance_restraint: False
ambiguous_distance_type: min
deffpow: 6
; TODO: move groupby_method to contactdef section
groupby_method: min
distance_type: fixed
; TODO: move parameters below to contactdef section
groupby_method: min
; Parameters below used only when distance_type is set to "fixed"
restraint_distance: 2.5
lower_bound: 1.0
......@@ -125,7 +123,6 @@ whatif_executable: whatif
; -------------------------- Contactmap parameters --------------------------- #
; Plot settings
n_factor: 1.5
groupby_method: min
save_fig: True
size_fig: 10
plot_ext: pdf
......
......@@ -39,8 +39,6 @@ class AriaEcBbConverter(object):
indent=4))
logger.debug("Args:\n" + json.dumps(self.settings.setup.args,
indent=4))
# Check output infrastructure
self.settings.make_infrastructure()
# TODO: redirect print output to logging ? (low priority)
# ----------------------------- Input -------------------------------- #
self.outprefix = get_filename(self.settings.bbconv.args.get("seq",
......@@ -50,14 +48,13 @@ class AriaEcBbConverter(object):
# Load secondary structure prediction file
self.protein.set_sec_struct(self.settings.bbconv.args.get("sspred",
None))
self.reader.add_file(self.settings.bbconv.args.get("contactfile"),
filetypelist=[self.settings.bbconv.args.get(
"contact_type")])
self.reader.read(self.protein,
self.reader.read(self.settings.bbconv.args.get("contactfile"),
filetypelist=[self.settings.bbconv.args.get("contact_type")],
protein=self.protein,
groupby_method=self.settings.setup.config['groupby_method'],
scsc=self.settings.scsc_min)
# ---------------------------- Processing ---------------------------- #
# Convert plmdca contacts in couplingmatrix file (CCMPred format)
# Convert contacts into couplingmatrix file (CCMPred format)
self.reader.filelist[0].mapdict["scoremap"].to_csv(
"%s/%s.mat" % (self.settings.outdir, self.outprefix),
index=False, header=False, sep="\t", float_format="%13.10f")
......
No preview for this file type
......@@ -87,26 +87,41 @@ class AriaEcSettings(Settings):
SCSC_MIN = 'data/scsc_min.p'
TOPO = 'data/topallhdg5.3.pro'
def __init__(self):
def __init__(self, name):
super(AriaEcSettings, self).__init__(("main", "setup", "contactmap",
"bbconv", "contactdef"))
self._infra = {"xml": '', "tbl": '', "others": ''}
self._infra = {}
self._scsc_min = None
self._ss_dist = None
self._template = None
self.outdir = os.getcwd()
self.infra = self.outdir
self.name = name
def _up_infra(self):
for d in self.infra:
logger.debug("set %s dir: %s" % (d, os.path.join(self.outdir, d)))
self._infra[d] = os.path.join(self.outdir, d)
@property
def infra(self):
if self.name == "setup" and not self._infra:
self._infra = {"xml": "", "tbl": "", "others": ""}
self._up_infra()
elif self.name == "contactmap" and not self._infra:
self._infra = {"graphics": ""}
self._up_infra()
return self._infra
@infra.setter
def infra(self, outdir):
self.outdir = os.path.abspath(outdir)
for d in self._infra:
logger.debug("set %s dir: %s" % (d, os.path.join(self.outdir, d)))
self._infra[d] = os.path.join(self.outdir, d)
def infra(self, root):
"""
Change infra root
:param root:
:return:
"""
self.outdir = os.path.abspath(root)
if self.infra:
self._up_infra()
@property
def scsc_min(self):
......@@ -132,7 +147,7 @@ class AriaEcSettings(Settings):
else:
return self._scsc_min
def make_infrastructure(self):
def make_infra(self):
logger.info("Making infrastructure in %s" % self.outdir)
for direct in self.infra:
logger.debug("Making %s directory" % self.infra[direct])
......
No preview for this file type
......@@ -56,7 +56,7 @@ class AriaEcContactMap(object):
self.file_reader.read(self.settings.contactmap.args.get("infiles"),
filetypelist=self.settings.contactmap.args.get("contact_types"),
protein=self.protein,
groupby_method=self.settings.contactmap.config[
groupby_method=self.settings.setup.config[
'groupby_method'],
scsc=self.settings.scsc_min)
......@@ -95,6 +95,7 @@ class AriaEcContactMap(object):
**plotparams)
continue
scoremap = self.allresmap[mapt].get('scoremap', None)
if self.allresmap[mapt].get("contactmap") is not None and \
self.allresmap[mapt].get("scoremap") is not None:
......@@ -121,8 +122,8 @@ class AriaEcContactMap(object):
# Write contact list in txt file
cmpmap.write_contacts("_".join((self.outprefix, mapt)),
outdir=outdir)
# Write comparison stats in csv file
cmpmap.compare_contactmap(refmap, cmplist, prefix,
# Write comparison stats
cmpmap.compare_contactmap(refmap, scoremap, cmplist, prefix,
distmap=self.refmap["distmap"],
human_idx=True,
outdir=outdir)
......
No preview for this file type
......@@ -2,15 +2,13 @@
ARIA Evolutionary Constraints Tools
"""
from __future__ import absolute_import, division, print_function
# import sys
import os
# ariapath = os.path.abspath(os.path.join(os.environ['ARIA2'], 'src/py'))
# sys.path.insert(0, ariapath)
import re
import matplotlib
matplotlib.use("Agg", warn=False)
import os
import re
import logging
import collections
import itertools
......@@ -290,10 +288,11 @@ class ProteinMap(Map):
if save_fig:
self.saveplot(**kwargs)
def compare_contactmap(self, cmpmap, contactlist, outprefix, outdir="",
distmap=None,
human_idx=True):
def compare_contactmap(self, cmpmap, scoremap, contactlist, outprefix,
outdir="", distmap=None, human_idx=True):
# CSV file giving TP/FP contacts
print(*self.astype(int).values.flat)
print(cmpmap.values)
outfile = open("%s/%s.contact.csv" % (outdir, outprefix), 'w')
logger.info("Writing stat file %s" % outfile)
offset = 1 if human_idx else 0
......
No preview for this file type
No preview for this file type
......@@ -39,8 +39,6 @@ class AriaEcSetup:
indent=4))
logger.debug("Args:\n" + json.dumps(self.settings.setup.args,
indent=4))
# Check output infrastructure
self.settings.make_infrastructure()
# -------------------------------------------------------------------- #
# ----------------------------- Input -------------------------------- #
# -------------------------------------------------------------------- #
......@@ -270,4 +268,4 @@ if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("Setup")
AriaEcSettings().load_config('aria_ec.ini')
AriaEcSettings('setup').load_config('aria_ec.ini')
No preview for this file type
......@@ -96,6 +96,7 @@ setup(
'pandas',
'seaborn',
'scipy',
'sklearn',
'colorlog',
# 'scikit-bio==0.4.0',
# 'aria==2.3'
......
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