Commit 381475a0 authored by fabrice's avatar fabrice

Bug fixe: wrong arguments for contactmaplot...

parent bf6fec2d
......@@ -264,5 +264,5 @@ if __name__ == "__main__":
# Test Logger
CustomLogging().set_outdir("../examples/out")
logger = logging.getLogger("TEST")
print(dir(logger))
logger.info(dir(logger))
logger.info("Log test")
No preview for this file type
......@@ -189,7 +189,6 @@ class AriaEcCommand:
logger.info("Loading default config file")
settings.load_config(self.default_confile, pkg=True)
if self.args.conf_file:
print(self.args.conf_file)
logger.info("Updating settings with conf file")
settings.load_config(self.args.conf_file)
# Update settings associated to command section
......@@ -208,7 +207,6 @@ class AriaEcCommand:
def setup(self):
setup_inst = AriaEcSetup(self.create_settings())
setup_inst.run()
# instantiate AriaEcSetup with AriaEcSettings
def bbconv(self):
bbconverter = AriaEcBbConverter(self.create_settings())
......
No preview for this file type
......@@ -127,7 +127,6 @@ reliable="{reliable}" list_name="{list_name}">
for contrib_id in restraint_dict[restraint_id]["contrib"]:
res_id = restraint_dict[restraint_id]["contrib"][contrib_id][
"spin_pair"].keys()
print(res_id)
xml_file.write('''\
<contribution id="{id}" weight="{weight}">
<spin_pair>
......@@ -423,7 +422,6 @@ class AriaEcXMLConverter(AriaXMLConverter):
# Number of selected contacts
nb_c = nb_c if nb_c < len(contactmap.contactset()) else len(
contactmap.contactset())
logger.info("Selecting %d contacts" % nb_c)
if scoremap is not None:
# TODO: implement viterbiscore as scoremap for bbcontacts ?
......@@ -442,7 +440,7 @@ class AriaEcXMLConverter(AriaXMLConverter):
nb_c)
# Initial contact list start at 0
# pair_list = [(int(x[0]) + 1, int(x[1]) + 1) for x in pair_list]
logger.debug(pair_list)
logger.info("Selecting %d contacts:\n%s" % (nb_c, pair_list))
if self.settings.setup.config['evfold_weight'] and scoremap is not None:
weight_list = list(float(10.0 / (x + 1)) for x, v in enumerate(
......@@ -501,8 +499,8 @@ class AriaEcXMLConverter(AriaXMLConverter):
for contactidx, contact in enumerate(pair_list):
# /!\ humanidx in contact must start at 1 !n_factor
print(contact)
# Add neighbors if neigh_flag
logger.debug("Contact %s" % str(contact))
resx_idx = range(min_ind(contact[0] - 1),
max_ind(contact[0] + 2, max_seqidx)) if \
neigh_flag else [contact[0]]
......
No preview for this file type
......@@ -82,8 +82,10 @@ class AriaEcContactMap(object):
for k in ('size_fig', 'plot_ext', 'plot_dpi')}
for mapt in self.allresmap.keys():
outdir = self.settings.outdir
prefix = "_".join((self.outprefix, mapt, self.reftype))
if mapt == self.reftype:
refmap.write_contacts("_".join((self.outprefix, mapt)),
outdir=outdir)
......@@ -91,6 +93,7 @@ class AriaEcContactMap(object):
outprefix="_".join((self.outprefix, mapt)),
**plotparams)
continue
if self.allresmap[mapt].get("contactmap") is not None and \
self.allresmap[mapt].get("scoremap") is not None:
......@@ -104,47 +107,33 @@ class AriaEcContactMap(object):
cmpmap = self.allresmap[mapt]["contactmap"]
cmplist = self.allresmap[mapt]['scoremap'].sortedset(
human_idx=True)
cmpmap.write_contacts("_".join((self.outprefix, mapt)),
outdir=outdir)
cmpmap.compare_contactmap(refmap, cmplist, prefix,
distmap=self.refmap["distmap"],
human_idx=True,
outdir=outdir)
# TODO: elementwise error with compare method
refmap.compare(cmpmap, outprefix=prefix,
out_dir=outdir,
save_fig=self.settings.contactmap.config.get(
"save_fig"),
alpha=self.settings.contactmap.config.get(
"alpha"),
**plotparams)
logger.info(pd.crosstab(cmpmap.to_series(), refmap.to_series(),
rownames=[mapt],
colnames=[self.reftype]))
elif self.allresmap[mapt].get("contactmap") is not None:
prefix = "_".join((self.outprefix, mapt, self.reftype))
outdir = self.settings.outdir
cmpmap = self.allresmap[mapt]["contactmap"]
cmplist = self.allresmap[mapt]['contactmap'].contact_list(
human_idx=True)
else:
logger.warning("%s map doesn't have any score related. Can't "
"define top list related to this map" % mapt)
continue
cmpmap.write_contacts("_".join((self.outprefix, mapt)),
# 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,
distmap=self.refmap["distmap"],
human_idx=True,
outdir=outdir)
cmpmap.compare_contactmap(refmap, cmplist, prefix,
distmap=self.refmap["distmap"],
human_idx=True,
outdir=outdir)
# TODO: elementwise error with compare method
refmap.compare(cmpmap, outprefix=prefix,
out_dir=outdir,
# Contact map comparison plot
# TODO: elementwise error with compare method
refmap.compareplot(cmpmap, outprefix=prefix,
outdir=outdir,
save_fig=self.settings.contactmap.config.get(
"save_fig"),
alpha=self.settings.contactmap.config.get(
"alpha"),
**plotparams)
logger.info(pd.crosstab(cmpmap.to_series(), refmap.to_series(),
rownames=[mapt], colnames=[self.reftype]))
else:
logger.warning("%s map doesn't have any score related. Can't "
"define top list related to this map" % mapt)
# Contingency table
logger.info(pd.crosstab(cmpmap.to_series(), refmap.to_series(),
rownames=[mapt], colnames=[self.reftype]))
No preview for this file type
......@@ -387,4 +387,4 @@ if __name__ == "__main__":
settings = AriaEcSettings()
prot = Protein(settings)
prot.set_aa_sequence("../examples/data/BPT1_BOVIN.fa")
print(prot.aa_sequence)
logger.info(prot.aa_sequence)
No preview for this file type
......@@ -244,22 +244,13 @@ class ProteinMap(Map):
# Indexation matrice (tous les atomes ou tous les residus)
raise NotImplementedError
def compare(self, protmap, save_fig=True, alpha=None, **kwargs):
def compareplot(self, protmap, save_fig=True, alpha=None, **kwargs):
# Contact map plot
if getattr(protmap, "shape") and self.shape != protmap.shape:
logging.error("Cant't compare %s map with %s" % (
protmap.__class__.__name__, self.__class__.__name__))
return None
else:
# Contact map Plot
# minticks = tickmin(self, shift=1) # Nb graduations
# f, ax = plt.subplots(figsize=(12, 9))
# contactmaplot = sns.heatmap(self, square=True, cbar=False,
# linewidths=1, vmax=1, vmin=-1,
# cmap=sns.diverging_palette(20, 220, n=7,
# as_cmap=True),
# xticklabels=minticks[0],
# yticklabels=minticks[1])
cmplist = protmap.contact_list()
ymax = len(self.sequence) - 1
......@@ -294,20 +285,6 @@ class ProteinMap(Map):
alpha=alpha)
if save_fig:
self.saveplot(**kwargs)
# tickrot(contactmaplot.axes, contactmaplot.figure,
# rotype='horizontal')
# contactmaplot.figure.set_size_inches(size_fig,
# size_fig)
# map_title = "%s contacts map" % outprefix
# contactmaplot.set_title(map_title)
# contactmaplot.figure.tight_layout()
#
# f.tight_layout()
# contactmaplot.figure.savefig(os.path.join(out_dir,
# "%s.contactmap.%s" % (
# outprefix,
# plot_ext)),
# dpi=plot_dpi)
def compare_contactmap(self, cmpmap, contactlist, outprefix, outdir="",
distmap=None,
......@@ -994,8 +971,8 @@ class MapFilter:
clash_list.extend(flt_res.get("clash"))
hum_list = [(x + 1, y + 1) for x, y in flt_res.get("clash")]
logger.info(
"Removed %d contacts: %s" % (len(flt_res.get("clash")) / 2,
hum_list))
"Removed %d contacts:\n%s" % (len(flt_res.get("clash")) / 2,
hum_list))
clash_dict[flt] = flt_res.get("clash")
if flt_res.get("desc"):
desc_dict.update(flt_res.get("desc"))
......
No preview for this file type
......@@ -78,7 +78,7 @@ class AriaEcSetup:
self.allresmap[fo.filetype] = fo.mapdict
if fo.filetype != "pdb" and "pdb" in self.allresmap:
fo.contactmap.compare(self.allresmap["pdb"])
fo.contactmap.compareplot(self.allresmap["pdb"])
# ---------------------------- target map ---------------------------- #
if self.settings.setup.args.get("distfile") and \
......
No preview for this file type
......@@ -86,8 +86,10 @@ setup(
# Project uses reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
setup_requires=['numpy >= 1.9.2',
'matplotlib'],
# TODO: check pandas setup in order to get rid of numpy installation error
setup_requires=[
'numpy',
'matplotlib'],
install_requires=[
'docutils>=0.3',
......
# Do not edit this file, pipeline versioning is governed by git tags
__version__=v0.1.3-dev1
\ No newline at end of file
__version__=v0.1.3-dev2
\ No newline at end of file
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