Commit 6dba452b authored by fabrice's avatar fabrice
Browse files

pep8tized

parent f57fc582
......@@ -102,19 +102,19 @@ def format_str(string):
:param string:
:return:
"""
if re.search("^\s*true\s*$", string, re.I):
if re.search(r"^\s*true\s*$", string, re.I):
return True
elif re.search("^\s*false\s*$", string, re.I):
elif re.search(r"^\s*false\s*$", string, re.I):
return False
elif re.search("^\s*\d+\s*$", string):
elif re.search(r"^\s*\d+\s*$", string):
return int(string)
elif re.search("^[\s\d-]+\.\d+\s*$", string):
elif re.search(r"^[\s\d-]+\.\d+\s*$", string):
return float(string)
elif "," in string:
return string.split(',')
elif "+" in string:
return string.split('+')
elif re.search("[/\\w]+", string):
elif re.search(r"[/\\w]+", string):
return string
else:
if string:
......
......@@ -28,7 +28,7 @@ def diversityvalue(msa, l):
"""
# Compute n value
msa_reg = re.compile("^>[A-Za-z0-9]+_[A-Za-z0-9]+")
msa_reg = re.compile(r"^>[A-Za-z0-9]+_[A-Za-z0-9]+")
n = 0
with open(msa) as f:
......
......@@ -78,7 +78,7 @@ class AriaEcBbConverter(object):
@staticmethod
def compute_diversityvalue(msa, l):
# Compute n value
msa_reg = re.compile("^>[A-Za-z0-9]+_[A-Za-z0-9]+")
msa_reg = re.compile(r"^>[A-Za-z0-9]+_[A-Za-z0-9]+")
n = 0
with open(msa) as f:
......
from __future__ import absolute_import, division, print_function
import numpy as np
def nd(mat, beta=0.99, alpha=1, control=0):
"""
This is a python implementation/translation of network deconvolution by MIT-KELLIS LAB
This is a python implementation/translation of network deconvolution by
MIT-KELLIS LAB
LICENSE: MIT-KELLIS LAB
......@@ -27,37 +30,42 @@ def nd(mat, beta=0.99, alpha=1, control=0):
DESCRIPTION:
USAGE:
mat_nd = ND(mat)
mat_nd = ND(mat,beta)
mat_nd = ND(mat,beta,alpha,control)
INPUT ARGUMENTS:
mat Input matrix, if it is a square matrix, the program assumes
it is a relevance matrix where mat(i,j) represents the similarity content
between nodes i and j. Elements of matrix should be
non-negative.
optional parameters:
beta Scaling parameter, the program maps the largest absolute eigenvalue
of the direct dependency matrix to beta. It should be
between 0 and 1.
alpha fraction of edges of the observed dependency matrix to be kept in
deconvolution process.
control if 0, displaying direct weights for observed
interactions, if 1, displaying direct weights for both observed and
USAGE:
mat_nd = ND(mat)
mat_nd = ND(mat,beta)
mat_nd = ND(mat,beta,alpha,control)
INPUT ARGUMENTS:
:type mat: np.matrix
:param mat: Input matrix, if it is a square matrix, the program assumes
it is a relevance matrix where mat(i,j) represents the
similarity content between nodes i and j. Elements of
matrix should be non-negative.
optional parameters:
:param beta: Scaling parameter, the program maps the largest absolute
eigenvalue of the direct dependency matrix to beta. It
should be between 0 and 1.
:param alpha: fraction of edges of the observed dependency matrix to be
kept in deconvolution process.
:param control: if 0, displaying direct weights for observed
interactions, if 1, displaying direct weights for both
observed and
non-observed interactions.
OUTPUT ARGUMENTS:
OUTPUT ARGUMENTS:
mat_nd Output deconvolved matrix (direct dependency matrix). Its components
represent direct edge weights of observed interactions.
Choosing top direct interactions (a cut-off) depends on the application and
is not implemented in this code.
mat_nd Output deconvolved matrix (direct dependency matrix). Its
components
represent direct edge weights of observed interactions.
Choosing top direct interactions (a cut-off) depends on
the application and
is not implemented in this code.
To apply ND on regulatory networks, follow steps explained in Supplementary notes
1.4.1 and 2.1 and 2.3 of the paper.
In this implementation, input matrices are made symmetric.
To apply ND on regulatory networks, follow steps explained in
Supplementary notes
1.4.1 and 2.1 and 2.3 of the paper.
In this implementation, input matrices are made symmetric.
**************************************************************************
loading scaling and thresholding parameters
......@@ -77,7 +85,7 @@ def nd(mat, beta=0.99, alpha=1, control=0):
diagonal values are filtered
'''
n = mat.shape[0]
# n = mat.shape[0]
np.fill_diagonal(mat, 0)
'''
......
......@@ -23,19 +23,19 @@ logger = logging.getLogger(__name__)
class SsList:
psipred_reg = re.compile('^(?P<up_index>\d+)'
'\s+(?P<up_residue>[AC-IK-NP-TVWYZ])'
'\s+(?P<ss_pred>[HEC])'
'\s+(?P<ss_conf>\d?)')
psipred_reg = re.compile(r'^(?P<up_index>\d+)'
r'\s+(?P<up_residue>[AC-IK-NP-TVWYZ])'
r'\s+(?P<ss_pred>[HEC])'
r'\s+(?P<ss_conf>\d?)')
indxplus_reg = re.compile(
'^(?P<up_index>\d+)\s+(?P<up_residue>[AC-IK-NP-TVWYZ])\s+'
'(?P<ss_pred>[CEH])\s+(?P<ss_conf>\d)\s+(?P<msa_index>[\d\-]+)\s+'
'(?P<msa_consper>[\d\-]+)\s+(?P<msa_cons>[\*~\-])\s+'
'(?P<in_const>[\*~\-])\s+(?P<pdb_atom>[\d\-]+)\s+'
'(?P<pdb_chain>[\-\w])\s+(?P<pdb_index>[\d\-]+\w?)\s+'
'(?P<pdb_residue>[AC-IK-NP-TVWYZ\-])\s+(?P<pdb_x_pos>[\d\.\-]+)\s+'
'(?P<pdb_y_pos>[\d\.\-]+)\s+(?P<pdb_z_pos>[\d\-\.]+)')
ss_dist_reg = re.compile("\s+(\d+\.\d+) \( (\d+\.\d+)\)")
r'^(?P<up_index>\d+)\s+(?P<up_residue>[AC-IK-NP-TVWYZ])\s+'
r'(?P<ss_pred>[CEH])\s+(?P<ss_conf>\d)\s+(?P<msa_index>[\d\-]+)\s+'
r'(?P<msa_consper>[\d\-]+)\s+(?P<msa_cons>[\*~\-])\s+'
r'(?P<in_const>[\*~\-])\s+(?P<pdb_atom>[\d\-]+)\s+'
r'(?P<pdb_chain>[\-\w])\s+(?P<pdb_index>[\d\-]+\w?)\s+'
r'(?P<pdb_residue>[AC-IK-NP-TVWYZ\-])\s+(?P<pdb_x_pos>[\d\.\-]+)\s+'
r'(?P<pdb_y_pos>[\d\.\-]+)\s+(?P<pdb_z_pos>[\d\-\.]+)')
ss_dist_reg = re.compile(r"\s+(\d+\.\d+) \( (\d+\.\d+)\)")
def __init__(self, sett):
self.settings = sett
......@@ -143,7 +143,7 @@ class SsList:
dist_sdev_list = self.ss_dist_reg.findall(line)
if line.startswith('i'):
atom_list = [elt.strip() for elt in line_list[1:]]
elif re.search('^([HE],[HE]\+\d)', line):
elif re.search(r'^([HE],[HE]\+\d)', line):
bond_type = line[0:5]
self.ssdist[bond_type] = {}
for i, (dist, sdev) in enumerate(dist_sdev_list):
......@@ -384,7 +384,7 @@ class Protein:
if __name__ == "__main__":
from .ecsettings import AriaEcSettings
settings = AriaEcSettings()
settings = AriaEcSettings("setup")
prot = Protein(settings)
prot.set_aa_sequence("../examples/data/BPT1_BOVIN.fa")
logger.info(prot.aa_sequence)
......@@ -454,6 +454,7 @@ class ProteinMap(Map):
else:
print("%d %d" % (contact[0], contact[1]), file=outfile)
class ResAtmMap(ProteinMap):
"""
Protein distance/contact matrix for all atom pairs. If no sequence given,
......@@ -470,7 +471,7 @@ class ResAtmMap(ProteinMap):
"""
# Matrix only for heavy atoms.
heavy_reg = re.compile("[CNOS][ABGDEZH][0-9]?")
heavy_reg = re.compile(r"[CNOS][ABGDEZH][0-9]?")
# TODO: Autre methodes de dist
distance_method = 'euclidean'
......
......@@ -12,8 +12,6 @@ from __future__ import absolute_import, division, print_function
# TODO: nc factor function
# TODO: Utiliser scikit-bio pour traiter les sequences biologiques
import sys
import os
import logging
# Adding aria path
......
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