Commit 57556cc5 authored by fabrice's avatar fabrice
Browse files

Flush before each maplot

parent 3108a9c6
......@@ -64,7 +64,13 @@ class AriaEcCommand:
def _update_logger(self, log):
if log and hasattr(self.args, "output_directory"):
log.set_outdir(self.args.output_directory)
if not self.args.nolog:
# Don't generate log files
# TODO: get handler list from json file or customlogging object
logger.removeHandler("info_file_handler")
logger.removeHandler("error_file_handler")
logger.removeHandler("debug_file_handler")
log.set_outdir(self.args.output_directory)
log.update_msg(self.args.command)
log.welcome()
......@@ -76,6 +82,8 @@ class AriaEcCommand:
type=str, help="Output directory")
parser.add_argument("-c", "--conf", action=ReadableFile, dest="conf_file",
default=None, help="configuration file")
parser.add_argument("--nolog", action="store_true",
default=False, help="Don't generate log files")
# Create subcommands
self._create_subparsers(parser.add_subparsers(dest="command"))
return parser
......@@ -173,6 +181,9 @@ class AriaEcCommand:
choices=self.contact_types, help="Infile(s) "
"contact "
"type(s)")
parser.add_argument("--merge", nargs="+", dest="merge",
choices=self.contact_types,
help="Merge given contact types with other maps")
parser.add_argument("--nofilter", dest="nofilter", action="store_true",
default=None, help="Do not use contact list "
"filter and select top n "
......@@ -201,7 +212,6 @@ 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
......@@ -61,7 +61,7 @@ cb_upper_bound: 7.0
; separated by "+" character [pos]. If empty, use only position
; filter (avoid short range restraints)
n_factor: 1.0
contactfilter: pos
contactfilter: all
conservation_treshold: 95
position_treshold: 5
nd_beta: 0.99
......
......@@ -148,9 +148,9 @@ class AriaEcSettings(Settings):
return self._scsc_min
def make_infra(self):
logger.info("Making infrastructure in %s" % self.outdir)
logger.info("Making output directories")
for direct in self.infra:
logger.debug("Making %s directory" % self.infra[direct])
logger.debug("Create %s directory" % self.infra[direct])
if not os.path.exists(self.infra[direct]):
os.makedirs(os.path.abspath(self.infra[direct]))
......
No preview for this file type
......@@ -33,6 +33,8 @@ class AriaEcContactMap(object):
indent=4))
logger.debug("Args:\n" + json.dumps(self.settings.contactmap.args,
indent=4))
if not self.settings.contactmap.args.get("onlyreport", False):
self.settings.make_infra()
# ----------------------------- Input -------------------------------- #
if self.settings.contactmap.args.get("prefix"):
self.outprefix = "_".join((get_filename(
......@@ -92,11 +94,27 @@ class AriaEcContactMap(object):
for k in ('size_fig', 'plot_ext', 'plot_dpi')}
outdir = self.settings.outdir
if self.settings.contactmap.config.get("save_fig"):
if self.settings.contactmap.config.get("save_fig") and not \
self.settings.contactmap.args.get("onlyreport", False):
refmap.saveplot(outdir=outdir,
outprefix="_".join((self.outprefix, "pdb")),
**plotparams)
if self.settings.contactmap.args.get("merge", None):
# Combine merge maps with other maps
mergelist = self.settings.contactmap.args.get("merge")
for mergetype in mergelist:
if mergetype in self.allresmap:
mergemaps = self.allresmap.pop(mergetype)
mergecontactmap = mergemaps.get("contactmap")
for mapt in self.allresmap.keys():
if mapt != self.reftype:
up_map = self.allresmap[mapt]["contactmap"]
up_map[:] = up_map.add(mergecontactmap)
mergekey = "%s_%s" % (mapt, mergetype)
self.allresmap[mergekey] = {}
self.allresmap[mergekey]["contactmap"] = up_map
for mapt in self.allresmap.keys():
prefix = "_".join((self.outprefix, mapt, self.reftype))
......@@ -139,7 +157,9 @@ class AriaEcContactMap(object):
outdir=outdir,
plotag=not self.settings.contactmap.args.get(
"onlyreport"),
plotdir=self.settings.infra.get("graphics", outdir))
plotdir=self.settings.infra.get("graphics", outdir)
if not self.settings.contactmap.args.get(
"onlyreport") else self.settings.outdir)
# Contact map comparison plot
# TODO: elementwise error with compare method
# Write cmp stats
......
No preview for this file type
......@@ -69,11 +69,7 @@ class Map(pd.DataFrame):
self.sym = sym
self.desc = desc
@staticmethod
def plotflush():
plt.clf()
plt.cla()
plt.close()
def sortedset(self, human_idx=False):
# Remove duplicate in sort_list
......@@ -190,13 +186,18 @@ class ProteinMap(Map):
def sequence(self):
raise NotImplementedError
def plotflush(self):
plt.clf()
plt.cla()
plt.close()
self._maplot = None
@property
def maplot(self):
# Contact map Plot
if not self._maplot:
# Flush matplot
logger.debug("Build maplot")
self.plotflush()
minticks = tickmin(self, shift=1) # Nb graduations
self._maplot = sns.heatmap(self, square=True, cbar=False,
......@@ -636,7 +637,7 @@ class ResAtmMap(ProteinMap):
"Filtering values in matrix related to %s (%s)" %
(str(pair), str(treshold)))
if pair in (("SC", "SC"), ("sc", "sc")):
# Use scsc_min to apply treshold only for selected atom
# Use scsc_min to apply treshold updateonly for selected atom
# sidechain
idx_list = []
col_list = []
......
No preview for this file type
......@@ -48,6 +48,7 @@ class AriaEcSetup:
indent=4))
logger.debug("Args:\n" + json.dumps(self.settings.setup.args,
indent=4))
self.settings.make_infra()
# -------------------------------------------------------------------- #
# ----------------------------- Input -------------------------------- #
# -------------------------------------------------------------------- #
......
No preview for this file type
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