Commit 381475a0 authored by fabrice's avatar fabrice

Bug fixe: wrong arguments for contactmaplot...

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