Commit c942dd3d authored by fabrice's avatar fabrice
Browse files

Added sequence information inside contactmap report

parent 2bedc483
No preview for this file type
No preview for this file type
......@@ -46,7 +46,7 @@ class Map(pd.DataFrame):
def __init__(self, index=None, columns=None, mtype='distance',
duplicate_levels=False, data=None, dtype=None, sym=True,
desc=""):
desc="", path=""):
"""
:param index:
:param columns:
......@@ -69,6 +69,7 @@ class Map(pd.DataFrame):
self.sort_list = []
self.sym = sym
self.desc = desc
self.path = path
def sortedset(self, human_idx=False):
# Remove duplicate in sort_list
......@@ -100,6 +101,7 @@ class Map(pd.DataFrame):
columns = ['-'.join(idx) for idx in self.columns]
index = ['-'.join(idx) for idx in self.index]
return getattr(self, '__init__')(self.sequence,
path=self.path,
data=self.as_matrix(),
index=index, desc=self.desc,
sym=self.sym, mtype=self.mtype,
......@@ -344,7 +346,15 @@ class ProteinMap(Map):
## Report {map1name} vs. {map2name}
##
## Date: {date}
## Path: {outdir}
##
## Plots: {outdir}
## Reference map: {map1path}
## Contact map: {map2path}
##
## -----------------------------------------------------------------------------
##
## Sequence: {seq}
## Protein length: {protlen}
##
## -----------------------------------------------------------------------------
##
......@@ -388,6 +398,8 @@ class ProteinMap(Map):
## {allfpr}
## Score tresholds ({map2name}):
## {rocthres}""".format(map1name=map1name, map2name=map2name,
map1path=self.path, map2path=cmpmap.path,
seq=self.sequence, protlen=len(self.sequence),
date=datetime.date.today().strftime("%A %d. %B %Y"),
outdir=outdir, accuracy=skm.accuracy_score(y_true, y_pred),
precision=skm.precision_score(y_true, y_pred),
......@@ -593,7 +605,7 @@ class ResAtmMap(ProteinMap):
if self.index.nlevels == 1 or not groupby:
return self
newmap = ResMap(self.sequence, dtype=self.dtype, desc=self.desc,
sym=self.sym)
sym=self.sym, path=self.path)
if self.dtype == bool:
newmap[:] = self.copy().stack().groupby(level=0).any()
elif groupby == "mean":
......@@ -619,7 +631,7 @@ class ResAtmMap(ProteinMap):
contactdef)
# Initialize contact map to a boolean matrix filled with False
contact_map = ResAtmMap(sequence=self.sequence, mtype="contact",
desc=self.desc, sym=self.sym)
desc=self.desc, sym=self.sym, path=self.path)
if type(contactdef) == float:
contact_map[:] = self.applymap(lambda x: x < contactdef)
......@@ -772,7 +784,7 @@ class AtmMap(Map):
pass
class ProtMapCollections:
class ProtMapCollection:
def __init__(self, settings):
self._alldistmap = None
......
No preview for this file type
......@@ -206,9 +206,10 @@ class MapFile(RegexFile):
# self.distmap = None
def create_map(self, protein, contactdef, flaglist=None, offset=0, sym=True,
**kwargs):
path="", **kwargs):
"""
:param path:
:param protein:
:param contactdef:
:param flaglist:
......@@ -351,7 +352,7 @@ class MapFile(RegexFile):
sym = False if self.filetype == "metapsicovhb" else True
self.create_map(protein, contactdef,
groupby_method=groupby_method, scsc=scsc,
flaglist=self.flaglist, sym=sym)
flaglist=self.flaglist, sym=sym, path=self.filepath)
if self.filetype == "plmdca":
# If contact filetype contain residues name, check if it is
# consistent with given sequence
......@@ -403,16 +404,17 @@ class ContactMapFile(MapFile):
flaglist=kwargs['flaglist'],
seqidx=protein.index, index=idxnames,
columns=colnames, sym=kwargs['sym'],
desc=self.filetype)
desc=self.filetype, path=kwargs.get("path"))
# DataFrame containing ec scores
scoremap = ResMap(protein.aa_sequence.sequence, mtype='score',
seqidx=protein.index, index=idxnames,
columns=colnames, sym=kwargs['sym'],
path=kwargs.get("path"),
desc=self.filetype) if self.sort else None
distmap = ResMap(protein.aa_sequence.sequence, mtype='distance',
seqidx=protein.index, index=idxnames, columns=colnames,
sym=kwargs['sym'], desc=self.filetype) if \
self.filetype == "metapsicovhb" else None
seqidx=protein.index, index=idxnames, path=kwargs.get("path"),
columns=colnames, sym=kwargs['sym'],
desc=self.filetype) if self.filetype == "metapsicovhb" else None
for contact_id in self.lines:
if self.filetype == "metapsicovhb":
......@@ -472,9 +474,9 @@ class PDBFile(MapFile):
**kwargs)
def create_map(self, protein, contactdef, groupby_method="min", scsc=None,
flaglist=None, sym=True):
flaglist=None, sym=True, path=""):
resmap = ResAtmMap(protein.aa_sequence.sequence, mtype='distance',
flaglist=flaglist,
flaglist=flaglist, path=path,
seqidx=protein.index, desc=self.filetype)
resmap[:] = self.update_map(resmap, sym=sym)
logger.debug("pdb distance map:\n%s" % resmap)
......@@ -536,7 +538,6 @@ class PDBFile(MapFile):
newmap.loc[:][idx] = None
logger.error("Can't update pdb distance map for pos in pdb file "
"%s with %s" % (list(error_list), missidx))
return newmap
......
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