示例#1
0
 def __init__(self, base, verbose):
     self.base = base
     self.to_convert = []
     self.mainlog = set_verbosity.verbosity(__name__, verbose)
     self.mainlog.debug('Creating new instance of Fetcher')
     dir_funcs.makebase(base, self.mainlog)
     return
示例#2
0
 def __init__(self, base, verbose):
     self.base = base
     self.to_convert = []
     self.mainlog = set_verbosity.verbosity(__name__, verbose)
     self.mainlog.debug('Creating new instance of Fetcher')
     dir_funcs.makebase(base, self.mainlog)
     return
示例#3
0
 def __init__(self, base, target, query, evalue, verbose):
     """Initialize the class with base directory, query sequence, e-value
     threshold and verbosity level."""
     self.query = query
     self.evalue = float(evalue)
     self.orthologues = {}
     self.mainlog = set_verbosity.verbosity('BLAST_Search', verbose)
     self.basedir = base
     self.target = target
     return
示例#4
0
 def __init__(self, base, target, query, evalue, verbose):
     """Initialize the class with base directory, query sequence, e-value
     threshold and verbosity level."""
     self.query = query
     self.evalue = evalue
     self.orthologues = {}
     self.mainlog = set_verbosity.verbosity('BLAST_Search', verbose)
     self.basedir = base
     self.target = target
     return
示例#5
0
 def __init__(self, base, deps, target, evalue, cfg, verbose):
     self.mainlog = set_verbosity.verbosity('Setup_Env', verbose)
     self.base = base
     self.deps = deps
     self.target_species = target
     self.eval_thresh = str(evalue)
     self.config_file = cfg
     self.missing_progs = []
     self.mainlog.debug('Config file in ' + self.config_file + '\n' +
                        'Setting variables: \n' + '#define BASE ' +
                        self.base + '\n' + '#define TARGET_SPECIES ' +
                        self.target_species + '\n' +
                        '#define EVAL_THRESHOLD ' + self.eval_thresh + '\n')
     self.bash_path = spawn.find_executable('bash') or ''
     self.gzip_path = spawn.find_executable('gzip') or ''
     self.sum_path = spawn.find_executable('sum') or ''
     self.tblastx_path = spawn.find_executable('tblastx') or ''
     self.pasta_path = spawn.find_executable('run_pasta.py') or ''
     self.hyphy_path = spawn.find_executable(
         'HYPHYMP') or spawn.find_executable('hyphymp') or ''
     self.clustalo_path = spawn.find_executable('clustalo') or ''
     self.fasttree_path = spawn.find_executable('fasttree') or ''
     self.mainlog.debug('Setting executable path variables:\n' +
                        '#define BASH ' + self.bash_path + '\n' +
                        '#define GZIP ' + self.gzip_path + '\n' +
                        '#define SUM ' + self.sum_path + '\n' +
                        '#define TBLASTX ' + self.tblastx_path + '\n' +
                        '#define PASTA ' + self.pasta_path + '\n' +
                        '#define HYPHY ' + self.hyphy_path + '\n' +
                        '#define CLUSTALO ' + self.clustalo_path + '\n' +
                        '#define FASTTREE ' + self.fasttree_path)
     #   Print out some warnings if executables are not found
     if self.bash_path == '':
         self.mainlog.error('Cannot find bash!')
     if self.gzip_path == '':
         self.mainlog.error('Cannot find gzip!')
     if self.sum_path == '':
         self.mainlog.error('Cannot find sum!')
     if self.tblastx_path == '':
         self.mainlog.warning('Cannot find tblastx!')
         self.missing_progs.append('tBLASTx')
     if self.pasta_path == '':
         self.mainlog.warning('Cannot find PASTA!')
         self.missing_progs.append('PASTA')
     if self.hyphy_path == '':
         self.mainlog.warning('Cannot find HyPhy!')
         self.missing_progs.append('HyPhy')
     if self.clustalo_path == '':
         self.mainlog.warning('Cannot find Clustal-omega!')
         self.missing_progs.append('ClustalO')
     if self.fasttree_path == '':
         self.mainlog.warning('Cannot find fasttree!')
         self.missing_progs.append('fasttree')
     return
示例#6
0
 def __init__(self, pasta_path, unaligned_sequences, query_sequence,
              verbose):
     self.mainlog = set_verbosity.verbosity('Pasta_Align', verbose)
     #   This is file-like object
     self.input_seq = unaligned_sequences
     #   This will be populated with sequences for back-translation
     self.input_dict = {}
     self.query = query_sequence
     self.pasta_path = check_modules.check_executable(pasta_path)
     self.protein_input = None
     self.aln_out = None
     self.tree_out = None
     self.final_aln = None
     return
示例#7
0
 def __init__(self, base, deps, target, evalue, cfg, verbose):
     self.mainlog = set_verbosity.verbosity('Setup_Env', verbose)
     self.base = base
     self.deps = deps
     self.target_species = target
     self.eval_thresh = str(evalue)
     self.config_file = cfg
     self.missing_progs = []
     self.mainlog.debug(
         'Config file in ' + self.config_file + '\n' +
         'Setting variables: \n' +
         '#define BASE ' + self.base + '\n' +
         '#define TARGET_SPECIES ' + self.target_species + '\n' +
         '#define EVAL_THRESHOLD ' + self.eval_thresh + '\n'
         )
     self.bash_path = spawn.find_executable('bash') or ''
     self.gzip_path = spawn.find_executable('gzip') or ''
     self.sum_path = spawn.find_executable('sum') or ''
     self.tblastx_path = spawn.find_executable('tblastx') or ''
     self.pasta_path = spawn.find_executable('run_pasta.py') or ''
     self.hyphy_path = spawn.find_executable('HYPHYMP') or spawn.find_executable('hyphymp') or ''
     self.mainlog.debug(
         'Setting executable path variables:\n' +
         '#define BASH ' + self.bash_path + '\n' +
         '#define GZIP ' + self.gzip_path + '\n' +
         '#define SUM ' + self.sum_path + '\n' +
         '#define TBLASTX ' + self.tblastx_path + '\n' +
         '#define PASTA ' + self.pasta_path + '\n' +
         '#define HYPHY ' + self.hyphy_path)
     #   Print out some warnings if executables are not found
     if self.bash_path == '':
         self.mainlog.error('Cannot find bash!')
     if self.gzip_path == '':
         self.mainlog.error('Cannot find gzip!')
     if self.sum_path == '':
         self.mainlog.error('Cannot find sum!')
     if self.tblastx_path == '':
         self.mainlog.warning('Cannot find tblastx! Will download')
         self.missing_progs.append('tBLASTx')
     if self.pasta_path == '':
         self.mainlog.warning('Cannot find PASTA! Will download')
         self.missing_progs.append('PASTA')
     if self.hyphy_path == '':
         self.mainlog.warning('Cannot find HyPhy! Will download')
         self.missing_progs.append('HyPhy')
     return
示例#8
0
 def __init__(
         self,
         pasta_path,
         unaligned_sequences,
         query_sequence,
         verbose):
     self.mainlog = set_verbosity.verbosity('Pasta_Align', verbose)
     #   This is file-like object
     self.input_seq = unaligned_sequences
     #   This will be populated with sequences for back-translation
     self.input_dict = {}
     self.query = query_sequence
     self.pasta_path = check_modules.check_executable(pasta_path)
     self.protein_input = None
     self.aln_out = None
     self.tree_out = None
     self.final_aln = None
     return
示例#9
0
def main():
    """The main function."""
    #   The very first thing we do is do a base check to make sure that we can
    #   parse arguments
    dep = check_modules.check_modules()
    if dep:
        check_modules.missing_mods(dep)
        exit(1)
    #   Parse the arguments
    #   First, a check to see if any arguments were sent at all
    #   If not, then print the usage and exit
    if not sys.argv[1:]:
        parse_args.usage()
        exit(1)
    #   Import the config handling script
    import lrt_predict.Setup.parse_config as config
    #   vars() will convert from the weird Namespace type to a dictionary
    arguments = vars(parse_args.parse_args())
    #   Pull out the verbosity switch right away
    loglevel = set_verbosity.verbosity('LRT_Predict', arguments['loglevel'])
    #   If the config variable was passed
    if 'config' in arguments:
        #   We ask then if the setup command was not passed
        #   If the user wants to setup, then don't bother trying to validate
        #   the config.
        if arguments['action'] != 'setup':
            cfg = config.ConfigHandler(
                arguments['config'],
                arguments,
                arguments['loglevel'])
            if cfg.is_valid():
                cfg.read_vars()
                config_opts = cfg.merge_options()
            else:
                loglevel.error('Config file is not valid!')
                exit(1)
        #   Else, just set it to the options that were passed
        else:
            config_opts = arguments
    else:
        config_opts = arguments
    arguments_valid, msg = parse_args.validate_args(config_opts, loglevel)
    #   If we got a return value that isn't False, then our arguments are good
    if arguments_valid:
        loglevel.debug(arguments_valid['action'] + ' subcommand was invoked')
        #   Which command was invoked?
        if arguments_valid['action'] == 'setup':
            setup(arguments_valid)
        elif arguments_valid['action'] == 'fetch':
            fetch(arguments_valid, loglevel)
        elif arguments_valid['action'] == 'align':
            #   We will return the filename that contains the unaligned
            #   sequences, as we will use these as inputs for pasta
            unaligned_seqs = blast(arguments_valid, loglevel)
            #   Then add the query sequence and align them
            align(
                arguments_valid,
                unaligned_seqs,
                loglevel)
        elif arguments_valid['action'] == 'predict':
            out = predict(arguments_valid, loglevel)
            #   copy the output file into the destination directory
            #   To build the output filename, we join the output directory
            #   with a new name based on the input filename
            out_fname = os.path.join(
                arguments_valid['output'],
                os.path.basename(
                    arguments_valid['fasta'].replace(
                        '.fasta',
                        '_Predictions.txt')
                    )
                )
            open(out_fname, 'w').close()
            shutil.copy2(out.name, out_fname)
            loglevel.info('Prediction in ' + out_fname)
        elif arguments_valid['action'] == 'compile':
            compile_preds(arguments_valid, loglevel)
            return
    else:
        loglevel.error(msg)
    return
示例#10
0
def main():
    """The main function."""
    #   The very first thing we do is do a base check to make sure that we can
    #   parse arguments
    dep = check_modules.check_modules()
    if dep:
        check_modules.missing_mods(dep)
        exit(1)
    #   Parse the arguments
    #   First, a check to see if any arguments were sent at all
    #   If not, then print the usage and exit
    if not sys.argv[1:]:
        parse_args.usage()
        exit(1)
    #   Import the config handling script
    import lrt_predict.Setup.parse_config as config
    #   vars() will convert from the weird Namespace type to a dictionary
    arguments = vars(parse_args.parse_args())
    #   Pull out the verbosity switch right away
    loglevel = set_verbosity.verbosity('LRT_Predict', arguments['loglevel'])
    #   If the config variable was passed
    if 'config' in arguments:
        #   We ask then if the setup command was not passed
        #   If the user wants to setup, then don't bother trying to validate
        #   the config.
        if arguments['action'] != 'setup':
            cfg = config.ConfigHandler(arguments['config'], arguments,
                                       arguments['loglevel'])
            if cfg.is_valid():
                cfg.read_vars()
                config_opts = cfg.merge_options()
            else:
                loglevel.error('Config file is not valid!')
                exit(1)
        #   Else, just set it to the options that were passed
        else:
            config_opts = arguments
    else:
        config_opts = arguments
    arguments_valid, msg = parse_args.validate_args(config_opts, loglevel)
    #   If we got a return value that isn't False, then our arguments are good
    if arguments_valid:
        loglevel.debug(arguments_valid['action'] + ' subcommand was invoked')
        #   Which command was invoked?
        if arguments_valid['action'] == 'setup':
            setup(arguments_valid)
        elif arguments_valid['action'] == 'fetch':
            fetch(arguments_valid, loglevel)
        elif arguments_valid['action'] == 'align':
            #   We will return the filename that contains the unaligned
            #   sequences, as we will use these as inputs for pasta
            unaligned_seqs = blast(arguments_valid, loglevel)
            #   Then add the query sequence and align them
            align(arguments_valid, unaligned_seqs, loglevel)
        elif arguments_valid['action'] == 'predict':
            out = predict(arguments_valid, loglevel)
            #   copy the output file into the destination directory
            #   To build the output filename, we join the output directory
            #   with a new name based on the input filename
            out_fname = os.path.join(
                arguments_valid['output'],
                os.path.basename(arguments_valid['fasta'].replace(
                    '.fasta', '_Predictions.txt')))
            open(out_fname, 'w').close()
            shutil.copy2(out.name, out_fname)
            loglevel.info('Prediction in ' + out_fname)
        elif arguments_valid['action'] == 'compile':
            compile_preds(arguments_valid, loglevel)
            return
    else:
        loglevel.error(msg)
    return
示例#11
0
 def __init__(self, outdir, verbose):
     self.preddir = outdir
     self.mainlog = set_verbosity.verbosity('HyPhy_Parser', verbose)
     return
示例#12
0
 def __init__(self, outdir, verbose):
     self.preddir = outdir
     self.mainlog = set_verbosity.verbosity('HyPhy_Parser', verbose)
     return