Exemplo n.º 1
0
def reads_mapping(sortmerna_bin,
                  fasta_ref_path,
                  index_ref_basepath,
                  reads_path,
                  output_basepath,
                  best,
                  min_lis,
                  evalue,
                  cpu,
                  verbose=False):

    logger.info('--- Reads mapping against scaffolds ---')
    logger.debug('Database:%s' % index_ref_basepath)
    parameters = {
        'fasta_ref': fasta_ref_path,
        'index_ref': index_ref_basepath,
        'reads': reads_path,
        'output': output_basepath,
        'best': best,
        'min': min_lis,
        'evalue': evalue,
        'cpu': cpu
    }

    cmd_line = '{bin} --ref {fasta_ref},{index_ref} --reads {reads} --aligned {output}' \
               ' --fastx --sam --blast "1" --log --best {best} --min_lis {min}' \
               ' -e {evalue:.2e} -a {cpu}'.format(bin=sortmerna_bin, **parameters)
    if verbose:
        cmd_line += ' -v'

    runner.logged_check_call(cmd_line, verbose=verbose)
Exemplo n.º 2
0
    def run(self):
        """
        Check I/O and simply run the command
        """

        if self.cmd_line is None:
            logger.fatal('You have to call "build_command_line" method before "run" method')
            sys.exit("No command line available")

        if self.fastq_file is None or not os.path.isfile(self.fastq_file):
            logger.fatal('The input reads file does not exists:%s' % self.fastq_file)
            sys.exit("Can't assemble %s" % self.fastq_file)

        if self.workdir is None:
            logger.debug("Workdir is not set")
            sys.exit("Can't assemble %s" % self.fastq_file)

        elif os.path.isdir(self.workdir):
            logger.debug("Remove previous assembler working dir before assembling:%s" % self.workdir)
            shutil.rmtree(self.workdir)
        os.mkdir(self.workdir)

        runner.logged_check_call(self.cmd_line)

        return self.fasta_file
Exemplo n.º 3
0
def make_krona_plot(krona_bin, krona_text_file, krona_html_file):
    logger.info('Make krona plot')
    logger.debug('Krona tab file:%s' % krona_text_file)
    cmd_line = '{bin} {txt} -o {html}'.format(bin=krona_bin,
                                              txt=krona_text_file,
                                              html=krona_html_file)

    runner.logged_check_call(cmd_line)
Exemplo n.º 4
0
def index_ref(indexdb_bin_path, input_fasta_ref_path, output_basepath, max_mem, verbose=False):
    logger.info('--- Indexing scaffolds ---')
    logger.debug('File to index:  %s' % input_fasta_ref_path)
    parameters = { 'input': input_fasta_ref_path, 'output': output_basepath, 'max_mem': max_mem }
    cmd_line = '{bin} --ref {input},{output} -m {max_mem}'.format(bin=indexdb_bin_path, **parameters)

    if verbose:
        cmd_line += ' -v'

    runner.logged_check_call(cmd_line, verbose=verbose)
Exemplo n.º 5
0
def get_best_matches(best_matches_bin, input_blast_path, out_blast_path, max_mem, cpu):

    outdir = os.path.dirname(out_blast_path)

    sort_bin = 'sort -T ' + outdir + ' -S ' + str(max_mem)
    sort_bin += 'M --parallel ' + str(cpu)

    cmd_line = sort_bin + ' -k1,1V -k12,12nr ' + input_blast_path
    cmd_line += ' | ' + best_matches_bin + ' -p 0.99 -o ' + out_blast_path

    runner.logged_check_call(cmd_line)
Exemplo n.º 6
0
def run_rdp_classifier(rdp_exe,
                       in_fasta,
                       out_classification_file,
                       cutoff=0.8,
                       gene='16srrna'):

    parameters = {
        'fa': in_fasta,
        'out': out_classification_file,
        'cutoff': cutoff,
        'gene': gene
    }
    cmd_line = '{rdp_exe} classify -c {cutoff} -f fixrank -g {gene} -o {out} {fa}'.format(
        rdp_exe=rdp_exe, **parameters)
    runner.logged_check_call(cmd_line)