Commit 5a496eea authored by Fabrice Allain's avatar Fabrice Allain
Browse files

started cnspatch command; add cli abstract command class

parent 794f14ee
......@@ -136,6 +136,12 @@ C mapyard module
C
C psearch module
CALL INIPSTCOMMON(.TRUE.)
c All modififications below done by Alexander Grishaev
c
c initialize database H-bonding term
call hbdbinit
C=====================================================================
C #endif
C=====================================================================
......@@ -273,6 +279,10 @@ C CALL READTENSO
CALL READHSHIFT
ELSE IF (WD(1:4).EQ.'MIND' ) THEN
CALL MINDWR
ELSE IF (WD(1:4).EQ.'HBDB' ) THEN
CALL READHBDB
C=====================================================================
C #endif
C=====================================================================
......
......@@ -21,7 +21,7 @@ C=====================================================================
Cif defined(CNS_SOLVE_COMPILE)
C=====================================================================
INTEGER SSJCOUP, SSCARB, SSPROT, SSONEJ, SSRAMA
INTEGER SSANGDB, SSSANI, SSDANI, SSVEAN
INTEGER SSANGDB, SSSANI, SSDANI, SSVEAN, SSHBDB
C=====================================================================
Cendif
C=====================================================================
......@@ -58,6 +58,8 @@ C=====================================================================
PARAMETER (SSSANI=36)
PARAMETER (SSDANI=37)
PARAMETER (SSVEAN=38)
PARAMETER (SSHBDB=39)
C=====================================================================
Cendif
C=====================================================================
......
......@@ -169,6 +169,16 @@ C
CALL EANGLEDB(RENR(SSANGDB), 'ENERGY ')
IF (TIMER.GT.1) CALL DSPCPU(' ENERGY: after angle DB term')
END IF
C
C H-bond database energy (A.G.)
C
IF (QENER(SSHBDB)) THEN
CALL EHBDB(RENR(SSHBDB), 'ENERGY ')
IF (TIMER.GT.1) CALL DSPCPU(' ENERGY: after H-bond DB term')
END IF
C=====================================================================
C #endif
C=====================================================================
......@@ -306,6 +316,8 @@ C=====================================================================
ANER(SSVEAN)='VEAN'
ANER(SSSANI)='SANI'
ANER(SSDANI)='DANI'
ANER(SSHBDB)='HBDB'
C=====================================================================
C #endif
C=====================================================================
......
This diff is collapsed.
c Backbone H-bonding database term (HBDB) data block
c Alexander Grishaev, NIH, 2003-2004
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
integer ndirpotmax,nlinpotmax,naamax,nhbmax
integer ndxmax,ndymax,ndzmax,ndrmax,ndtmax,natmax
parameter (ndirpotmax = 11)
parameter (nlinpotmax = 4)
parameter (natmax = 12000)
parameter (naamax = 1000)
parameter (nhbmax = 700)
parameter (ndxmax = 62)
parameter (ndymax = 62)
parameter (ndzmax = 33)
parameter (ndrmax = 30)
parameter (ndtmax = 30)
integer ndirpot,nlinpot
integer nresid(natmax)
integer ndr,ndt,ndx,ndy,ndz
integer hbfixijstor(nhbmax,4),hbfreeijstor(nhbmax,4)
integer nhbfix,nhbfree
integer hbfixres(nhbmax,2),hbfreeres(nhbmax,2)
integer hbnat(naamax,2)
integer hbmap(naamax,naamax)
integer nminhb(10),nmaxhb(10),nseghb
integer hbupdfrq,hbprnfrq
integer ihb,ihbfree,ihbfix
c BARDIAUX
integer skipinter
ccccccccccccccccccccccccccccccccc
integer minfindd,minfindl
integer lenfiledir(ndirpotmax),lenfilelin(nlinpotmax)
integer update
integer idfixpot(nhbmax,2),idfreepot(nhbmax,2)
integer frameid(natmax,3),donid(natmax,2)
integer nhbact
integer idres(naamax),totres
double precision edir(ndirpotmax,ndxmax,ndymax,ndzmax)
double precision fdir(ndirpotmax,ndxmax,ndymax,ndzmax,3)
double precision elin(nlinpotmax,ndrmax,ndtmax)
double precision flin(nlinpotmax,ndrmax,ndtmax)
double precision kdir,klin
double precision kdirmin,klinmin
double precision renf,kenf
double precision dxyz,dr,dt
double precision offr,offt,offx,offy,offz
double precision xmin,ymin,zmin,xmax,ymax,zmax
double precision rcut,tcut3,tcut45,tttcut
double precision hbfixstor(nhbmax,6),hbfixprop(naamax,naamax,4)
double precision hbfreestor(nhbmax,6),hbfreeprop(naamax,naamax,4)
double precision dirmin(ndirpotmax,3),linmin(nlinpotmax,ndrmax)
double precision ntotdir,ntotlin,etotdir,etotlin
double precision ct,st,cp,sp,cp1,sp1,ct1,st1
double precision etothb
character rname(naamax)*3
character dirpotype(ndirpotmax)*12
character linpotype(nlinpotmax)*5
character filedir(ndirpotmax)*512,filelin(nlinpotmax)*512
character hbfixat(nhbmax,2)*4,hbfreeat(nhbmax,2)*4
character hbfixseg(nhbmax,2)*4,hbfreeseg(nhbmax,2)*4
character segrangehb(10)*4
character segres(naamax)*4
common /intvar/
& ndirpot,nlinpot,
& nresid,
& ndr,ndt,ndx,ndy,ndz,
& hbfixijstor,hbfreeijstor,
& nhbfix,nhbfree,
& hbfixres,hbfreeres,
& hbmap,
& nminhb,nmaxhb,nseghb,
& hbupdfrq,hbprnfrq,
& ihb,ihbfree,ihbfix,
& minfindd,minfindl,
& update,
& frameid,donid,
& nhbact,
& hbnat,
& idfixpot,idfreepot,
& idres,totres,
c BARDIAUX
& skipinter
common /fpvar /
& edir,fdir,
& elin,flin,
& kdir,klin,
& kdirmin,klinmin,
& renf,kenf,
& dxyz,dr,dt,
& offr,offt,
& offx,offy,offz,
& xmin,ymin,zmin,
& xmax,ymax,zmax,
& rcut,tcut3,tcut45,tttcut,
& hbfixstor,hbfixprop,
& hbfreestor,hbfreeprop,
& dirmin,linmin,
& ntotdir,ntotlin,etotdir,etotlin,
& ct,st,cp,sp,cp1,sp1,ct1,st1,etothb
common /charvar / rname,
& dirpotype,linpotype,
& filedir,filelin,
& hbfixat,hbfreeat,hbfixseg,segrangehb,segres
# coding=utf-8
"""
CNS patch tool
"""
from __future__ import absolute_import, division, print_function
import os
from conbox.commands import CLI
CNS_PATH = 'CNS_SOLVE'
class CNSPatchCommand(CLI):
"""
CLI for cns compilation with ARIA files
"""
command_list = ('ariacns', )
desc_list = (
u"Compile a new CNS executable according with ARIA CNS patches", )
def __init__(self):
super(CNSPatchCommand, self).__init__()
def _ariacns_argparser(self):
pass
def ariacns(self):
"""
CNS patch command which compile a new CNS executable
"""
pass
# def cns_patch():
# Check if CNS_SOLVE environment variable exists
# In this case we will compile the new executable which include ARIA cns files
#
def main():
"""Launch ariaec command interface"""
command = CNSPatchCommand()
command.run()
......@@ -9,6 +9,7 @@ import logging
import argparse as argp
from . import __doc__
from abc import ABCMeta, abstractproperty
from .common import format_dict, CustomLogging
from .settings import AriaEcSettings
from .maplot import AriaEcContactMap
......@@ -50,11 +51,24 @@ def check_file(prospective_file):
def seqrange_type(s):
"""
Convert a string as a 2-tuple of int values
Parameters
----------
s : str
String containing int values separated by dash character
Returns
-------
tuple
2-tuple of int values
"""
try:
x, y = map(int, s.split('-'))
return x, y
except:
raise argp.ArgumentTypeError("Sequence indexes must be start-end")
raise argp.ArgumentTypeError("Indexes must be start-end")
class ReadableFile(argp.Action):
......@@ -74,78 +88,45 @@ class ReadableFile(argp.Action):
setattr(namespace, self.dest, os.path.abspath(os.path.expanduser(values)))
# TODO: Make parent Command class with _create_argparser, self.args,
# update_logger and run
class AriaEcCommands(object):
class CLI(object):
"""
Command line interface for aria_ec
Attributes
----------
AriaEcCommands.command_list: list
available command line tools
AriaEcCommands.desc_list: list
Abstract class for command line interface
"""
__metaclass__ = ABCMeta
command_list = ("setup", "bbconv", "maplot", "pdbqual", "analysis",
"tbl2xml", "pdbdist", "pdbstat", "iniconv")
desc_list = (u"Setup ARIA infrastructure with contact maps translated "
u"into ARIA restraints",
u"Convert a contact map in bbcontact format",
u"Contactmap visualization tool",
u"Quality tool for pdb file(s)",
u"Extended ARIA ensemble analysis on a specific iteration ",
u"XML converter for tbl distance restraint",
u"Extract distance distribution from culled list of pdb files",
u"Analyze distance distribution with GMM",
u"Convert configuration files into a unique csv file")
def __init__(self, logger=CustomLogging(desc=__doc__)):
self._parser = self._create_argparser()
self.args = self._parser.parse_args()
self._update_logger(logger)
contact_types = set(MapFile.types).union(
set(CONTACT_FILE_PARSERS))
default_confile = "conf/config.ini"
def __init__(self, custom_logging=None):
# Def Argument pdbparser
parser = self._create_argparser()
# parse args
self.args = parser.parse_args()
# Update LOG with outdir
self._update_logger(custom_logging)
@abstractproperty
def command_list(self):
"""
List of commands available in the CLI
"""
raise NotImplementedError
def _update_logger(self, log):
@abstractproperty
def desc_list(self):
"""
List of command description in the CLI (should follow the same order as
the command_list attribute)
"""
raise NotImplementedError
Parameters
----------
log :
def _create_argparser(self):
"""
Create main argument parser with basic options
Returns
-------
argparse.ArgumentParser
"""
if log and hasattr(self.args, "output_directory"):
if not self.args.nolog:
# Don't generate log files
# TODO: get handler list from json file or customlogging object
LOG.removeHandler("info_file_handler")
LOG.removeHandler("error_file_handler")
LOG.removeHandler("debug_file_handler")
log.set_outdir(self.args.output_directory)
log.update_msg(self.args.command)
def _create_argparser(self):
parser = argp.ArgumentParser(
description=__doc__,
formatter_class=argp.ArgumentDefaultsHelpFormatter)
parser.add_argument("-o", "--output", dest="output_directory",
type=str, help="Output directory", required=True)
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")
parser.add_argument("-d", "--debug", dest="verbose", default=False,
......@@ -161,21 +142,93 @@ class AriaEcCommands(object):
Parameters
----------
parser :
argparser object
parser : :class:`argparse.ArgumentParser`
argument parser instance
Returns
-------
None
"""
# TODO: find a way to raise NotImplementedError for each non defined
# command_argparser
for index, command in enumerate(self.command_list):
# Create subparser defined in command list
subcommand = getattr(self, "_" + command + "_argparser")(
desc=self.desc_list[index])
# TODO: the best way to save argparsers ?
setattr(self, "_" + command + "_argparser",
argp.ArgumentParser(description=self.desc_list[index],
add_help=False))
subcommand = getattr(self, "_" + command + "_argparser")
# TODO: Not the right way ?
parser.add_parser(command, parents=[subcommand])
def _setup_argparser(self, desc=None):
def _update_logger(self, log):
"""
If output directory is provided, change location of log files
Parameters
----------
log : :class:`aria.conbox.Customlogging`
"""
if log and hasattr(self.args, "output_directory"):
if not self.args.nolog:
# Don't generate log files
# TODO: get handler list from json file or customlogging object
LOG.removeHandler("info_file_handler")
LOG.removeHandler("error_file_handler")
LOG.removeHandler("debug_file_handler")
log.set_outdir(self.args.output_directory)
log.update_msg(self.args.command)
def run(self):
"""Call method relative to args.command"""
LOG.debug("Run %s command", self.args.command)
# TODO: find a way to raise NotImplementedError for non defined command(s)
getattr(self, self.args.command)()
class AriaEcCommands(CLI):
"""
Command line interface for aria_ec
Attributes
----------
AriaEcCommands.command_list: list
available command line tools
AriaEcCommands.desc_list: list
"""
command_list = ("setup", "bbconv", "maplot", "pdbqual", "analysis",
"tbl2xml", "pdbdist", "pdbstat", "iniconv")
desc_list = (u"Setup ARIA infrastructure with contact maps translated "
u"into ARIA restraints",
u"Convert a contact map in bbcontact format",
u"Contactmap visualization tool",
u"Quality tool for pdb file(s)",
u"Extended ARIA ensemble analysis on a specific iteration ",
u"XML converter for tbl distance restraint",
u"Extract distance distribution from culled list of pdb files",
u"Analyze distance distribution with GMM",
u"Convert configuration files into a unique csv file")
contact_types = set(MapFile.types).union(
set(CONTACT_FILE_PARSERS))
default_confile = "conf/config.ini"
def __init__(self, logger=None):
super(AriaEcCommands, self).__init__(logger)
def _create_argparser(self):
"""
Update default CLI in order to add the confi
"""
parser = super(AriaEcCommands, self)._create_argparser()
parser.add_argument("-c", "--conf", action=ReadableFile,
dest="conf_file",
default=None, help="configuration file")
return parser
def _setup_argparser(self):
"""
setup opt & args
......@@ -189,8 +242,7 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._setup_argparser
# Options
# Args
group = parser.add_argument_group('required arguments')
......@@ -236,7 +288,7 @@ class AriaEcCommands(object):
"is defined with -p option")
return parser
def _bbconv_argparser(self, desc=None):
def _bbconv_argparser(self):
"""
bbconv opt & args
......@@ -250,8 +302,7 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._bbconv_argparser
# args
parser.add_argument("contactfile", help="contacts file (pconsc, plm)",
action=ReadableFile)
......@@ -266,8 +317,7 @@ class AriaEcCommands(object):
"type")
return parser
@staticmethod
def _iniconv_argparser(desc=None):
def _iniconv_argparser(self):
"""
iniconv opt & args
......@@ -281,14 +331,13 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._iniconv_argparser
# args
parser.add_argument("confiles", nargs='+',
type=str, help="config files")
return parser
def _maplot_argparser(self, desc=None):
def _maplot_argparser(self):
"""
maplot opt & args
......@@ -302,8 +351,7 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._maplot_argparser
parser.add_argument("seq", action=ReadableFile,
help="sequence file [FASTA]")
parser.add_argument("sspred", action=ReadableFile,
......@@ -339,8 +387,7 @@ class AriaEcCommands(object):
help="Prefix name for file names")
return parser
@staticmethod
def _pdbqual_argparser(desc=None):
def _pdbqual_argparser(self):
"""
......@@ -354,16 +401,14 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._pdbqual_argparser
parser.add_argument("infiles", nargs="+", metavar="infile",
action=ReadableFile,
help="PDB file(s) used to run quality tools with "
"aria API")
return parser
@staticmethod
def _analysis_argparser(desc=None):
def _analysis_argparser(self):
"""
......@@ -377,8 +422,7 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._analysis_argparser
parser.add_argument("project", action=ReadableFile,
help="ARIA project file [XML]")
parser.add_argument("iteration", metavar="iteration_path",
......@@ -398,8 +442,7 @@ class AriaEcCommands(object):
help="Prefix name for file names")
return parser
@staticmethod
def _tbl2xml_argparser(desc=None):
def _tbl2xml_argparser(self):
"""
......@@ -413,8 +456,7 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._tbl2xml_argparser
parser.add_argument(
"molecule", metavar="molecule.xml", action=ReadableFile,
help="ARIA XML molecule file")
......@@ -425,8 +467,7 @@ class AriaEcCommands(object):
help="TBL distance restraint file(s)")
return parser
@staticmethod
def _pdbdist_argparser(desc=None):
def _pdbdist_argparser(self):
"""
......@@ -440,8 +481,7 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._pdbdist_argparser
# TODO: find a way to list all cullpdb file in package ressources
# Maybe move this args to the config file
......@@ -459,8 +499,7 @@ class AriaEcCommands(object):
help="Folder containing pdb file entries")
return parser
@staticmethod
def _pdbstat_argparser(desc=None):
def _pdbstat_argparser(self):
"""
......@@ -474,8 +513,7 @@ class AriaEcCommands(object):
"""
parser = argp.ArgumentParser(description=desc,
add_help=False)
parser = super(AriaEcCommands, self)._pdbstat_argparser
# TODO: find a way to list all cullpdb file in package ressources
# Maybe move this args to the config file
......@@ -517,11 +555,6 @@ class AriaEcCommands(object):
settings.infra = self.args.output_directory
return settings