Commit 284f8974 authored by Fabrice  ALLAIN's avatar Fabrice ALLAIN
Browse files

Added pdbdist cmd

parent b2b22a4f
......@@ -14,6 +14,7 @@ from .maplot import AriaEcContactMap
from .econverter import AriaEcBbConverter, AriaEcXMLConverter
from .setup import AriaEcSetup
from .pdbqual import AriaEcPdbqual
from .pdbdist import PDBDist
LOG = logging.getLogger(__name__)
......@@ -59,17 +60,19 @@ class AriaEcCommand(object):
Argparse interface for aria_ec
"""
command_list = ("setup", "bbconv", "contactmap", "pdbqual", "tbl2xml")
command_list = ("setup", "bbconv", "contactmap", "pdbqual", "tbl2xml",
"pdbdist")
desc_list = (u"Setup ARIA infrastructure with given contacts translated "
u"into ARIA restraints",
u"Convert contacts in bbcontact format",
u"Contactmap tool",
u"Quality tool for pdb file(s)",
u"XML converter for tbl distance restraint")
contact_types = ("evfold", "plmev", "plm", "plmdca", "plmc", "bbcontacts", "pconsc", "pconsc1",
"pconsc2", "psicov", "metapsicovhb", "metapsicov_stg1",
"metapsicov_stg2", "gremlin", "pdb", "native",
"native_full", "contactlist")
u"XML converter for tbl distance restraint",
u"Extract distance distribution from culled list of pdb files")
contact_types = ("evfold", "plmev", "plm", "plmdca", "plmc", "bbcontacts",
"pconsc", "pconsc1", "pconsc2", "psicov", "metapsicovhb",
"metapsicov_stg1", "metapsicov_stg2", "gremlin", "pdb",
"native", "native_full", "contactlist")
default_confile = "conf/aria_ec.ini"
def __init__(self, custom_logging=None):
......@@ -249,6 +252,20 @@ class AriaEcCommand(object):
help="TBL distance restraint file(s)")
return parser
@staticmethod
def _pdbdist_argparser(desc=None):
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser.add_argument(
"--cullist", dest="cullpdbs", default=None,
metavar="CULLED_PDB_LIST", action=ReadableFile,
help="Culled list of pdb files")
parser.add_argument(
"--pdbdir", dest="pdbdir", default=None,
metavar="PDB_FOLDER",
help="Folder containing pdb file entries")
return parser
def create_settings(self):
"""Create settings relative to args.command"""
......@@ -303,7 +320,6 @@ class AriaEcCommand(object):
def pdbqual(self):
"""
Quality run subcommand
:return:
"""
qualprot = AriaEcPdbqual(self.create_settings())
qualprot.run()
......@@ -311,19 +327,21 @@ class AriaEcCommand(object):
def tbl2xml(self):
"""
tbl2xml command
Returns
-------
"""
tblconverter = AriaEcXMLConverter(self.create_settings())
tblconverter.run_tbl2xml()
def pdbdist(self):
"""
Extract pdb distance distributions
"""
inst = PDBDist(self.create_settings())
inst.run()
def ec2aria():
"""
Launch ariaec command interface
:return:
"""
mylog = CustomLogging(desc="ARIA Evolutionary Constraints Tools")
......
......@@ -113,9 +113,11 @@ class AriaEcSettings(Settings):
ARIAPROJ_TEMPLATE = 'templates/aria_project_v2.3.0.xml'
SS_DIST = 'data/ss_dist.txt'
SCSC_MIN = 'data/scsc_min.p'
CULLEDPDBS = 'data/cullpdb/160427/cullpdb_pc25_res1.6_R0.25_d160427_chains3743'
# TODO: If aria installed in site-packages, use topallhdg file from aria !
TOPO = 'data/topallhdg5.3.pro'
SECTIONS = ("main", "setup", "contactmap", "bbconv", "contactdef", "pdbqual")
SECTIONS = ("main", "setup", "contactmap", "bbconv", "contactdef",
"pdbqual", "pdbdist")
def __init__(self, name):
"""
......
# coding=utf-8
"""
PDB distance distribution analysis
"""
import os
import logging
from future.builtins import input
from Bio.PDB import PDBList
LOG = logging.getLogger(__name__)
class PDBDist(object):
"""
Exrtact pdb distance distribution
"""
def __init__(self, settings):
self.settings = settings
def run(self):
"""
main method
"""
print(self.settings.pdbdist.args.get("pdbdir"))
print(self.settings.pdbdist.args.get("cullpdbs"))
# LOG.warning("PDB directory not given. PDBDist command has to download "
# "all pdb files. This step could take at lot of time and "
# "memory. Do you really want to continue ? [Y/N]")
# if input() not in ("y", "Y", "yes", "Yes", "YES"):
# return
print("test")
pdbl = PDBList()
pdbl.retrieve_pdb_file(
'1FAT', pdir=self.settings.pdbdist.args.get('output_directory',
os.getcwd()))
# Pour des raisons pratiques, les distances ne sont pas conservées entre
# chaque iteration dans la boucle
# Parcourt la liste des pdbs
# Ajoute l'ensemble des distances via la fonction self.get_dist
pass
\ No newline at end of file
......@@ -22,9 +22,10 @@ from .base import (reg_load, ppdict)
LOG = logging.getLogger(__name__)
# TODO: implement psipred format 3.5
class SsList(object):
"""
Secondary structure prediction class
Reader for secondary prediction structure files
"""
psipred_reg = re.compile(r'^(?P<up_index>\d+)'
r'\s+(?P<up_residue>[AC-IK-NP-TVWYZ])'
......@@ -74,11 +75,10 @@ class SsList(object):
self.filetype = os.path.splitext(filename)[1][1:]
# TODO: check if given file is supported
def read(self, filename, sequence=''):
def read(self, filename):
"""
:param filename:
:param sequence:
:return:
"""
self.check_filetype(filename)
......@@ -90,11 +90,6 @@ class SsList(object):
else:
self.read_psipred(filename)
# TODO: since Protein.set_sec_struct call seq_sublist, should remove
# line below
# if sequence:
# self.seq_sublist(sequence)
LOG.debug("Secondary structure list:\n%s\n"
"Secondary structure dict:\n%s", self.ss_matrix,
self.ssdict)
......@@ -140,8 +135,8 @@ class SsList(object):
:return:
"""
with open(filename, 'w') as psipred:
psipred.write("> %s\n" % desc)
psipred.write("".join([_[0] for _ in zip(*self.ss_matrix)[2]]))
psipred.write(str("> %s\n" % desc))
psipred.write(str("".join([_[0] for _ in zip(*self.ss_matrix)[2]])))
def read_indextableplus(self, filename):
"""
......
......@@ -286,7 +286,7 @@ class AriaEcSetup(object):
outfile.write('''
# TP number : {tp} ({ptp:.2f} %)
# Number of contacts : {nc}
'''.format(tp=tp_count, ptp=ptp, nc=len(contacts)))
'''.format(tp=tp_count, ptp=ptp, nc=len(contacts)))
if __name__ == "__main__":
......
......@@ -163,6 +163,7 @@ def setup_package():
# Project uses reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
install_requires=[
'biopython>=1.68',
'future>=0.15',
'docutils>=0.3',
'six>=1.10',
......
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