Ejemplo n.º 1
0
 def test_compute_min_alignment_length(self):
     """compute_min_alignment_length: returns n std devs below mean seq len
     """
     self.assertEqual(compute_min_alignment_length(\
                      self.min_length_computation_seqs),16)
     self.assertEqual(compute_min_alignment_length(\
                      self.min_length_computation_seqs,0.60),13)
Ejemplo n.º 2
0
 def test_compute_min_alignment_length(self):
     """compute_min_alignment_length: returns n std devs below mean seq len
     """
     self.assertEqual(compute_min_alignment_length(
                      self.min_length_computation_seqs), 16)
     self.assertEqual(compute_min_alignment_length(
                      self.min_length_computation_seqs, 0.60), 13)
Ejemplo n.º 3
0
 def _precommand_initiation(self,input_fp,output_dir,working_dir,params):
     if not params['blast_db']:        
         # Build the blast database from the reference_seqs_fp -- all procs
         # will then access one db rather than create one per proc
         blast_db, db_files_to_remove = \
              build_blast_db_from_fasta_path(params['template_fp'])
         self.files_to_remove += db_files_to_remove
         params['blast_db'] = blast_db
     
     if params['min_length'] < 0:
         params['min_length'] = compute_min_alignment_length(\
                                 open(input_fp,'U'))
Ejemplo n.º 4
0
 def _precommand_initiation(self,input_fp,output_dir,working_dir,params):
     if not params['blast_db']:        
         # Build the blast database from the reference_seqs_fp -- all procs
         # will then access one db rather than create one per proc
         blast_db, db_files_to_remove = \
              build_blast_db_from_fasta_path(params['template_fp'])
         self.files_to_remove += db_files_to_remove
         params['blast_db'] = blast_db
     
     if params['min_length'] < 0:
         params['min_length'] = compute_min_alignment_length(\
                                 open(input_fp,'U'))
Ejemplo n.º 5
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.min_percent_id <= 1.0:
        opts.min_percent_id *= 100

    if not (1.0 <= opts.min_percent_id <= 100.0):
        option_parser.error('Minimum percent sequence identity must be' +
                            ' between 1.0 and 100.0: %2.2f' % opts.min_percent_id)

    if not opts.template_fp and opts.alignment_method == 'pynast':
        option_parser.error(
            'PyNAST requires a template alignment to be passed via -t')

    input_seqs_filepath = opts.input_fasta_fp
    alignment_method = opts.alignment_method
    output_dir = opts.output_dir or alignment_method + '_aligned'
    create_dir(output_dir, fail_on_exist=False)

    # compute the minimum alignment length if a negative value was
    # provided (the default)
    min_length = opts.min_length
    if min_length < 0:
        min_length = compute_min_alignment_length(
            open(input_seqs_filepath, 'U'))

    fpath, ext = splitext(input_seqs_filepath)
    input_dir, fname = split(fpath)

    result_path = output_dir + '/' + fname + "_aligned.fasta"
    log_path = output_dir + '/' + fname + "_log.txt"
    failure_path = output_dir + '/' + fname + "_failures.fasta"

    if alignment_method in alignment_method_constructors:
        # try/except was causing problems here, so replacing with
        # an explicit check
        # define the aligner params
        aligner_constructor =\
            alignment_method_constructors[alignment_method]
        aligner_type = alignment_method
        params = {'min_len': min_length,
                  'min_pct': opts.min_percent_id,
                  'template_filepath': opts.template_fp,
                  'blast_db': opts.blast_db,
                  'pairwise_alignment_method': opts.pairwise_alignment_method}
        # build the aligner object
        aligner = aligner_constructor(params)
        # apply the aligner
        aligner(input_seqs_filepath, result_path=result_path,
                log_path=log_path, failure_path=failure_path)
    else:
        # define the aligner params
        aligner = CogentAligner({
            'Module': alignment_module_names.get(alignment_method, 'Unknown'),
            'Method': alignment_method
        })
        if alignment_method == "muscle":
            if opts.muscle_max_memory is not None:
                aligner.Params["-maxmb"] = str(opts.muscle_max_memory)
        # build the aligner
        aligner_type = 'Cogent'
        # apply the aligner
        aligner(result_path, seq_path=input_seqs_filepath,
                log_path=log_path)
Ejemplo n.º 6
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.min_percent_id <= 1.0:
        opts.min_percent_id *= 100

    if not (1.0 <= opts.min_percent_id <= 100.0):
        option_parser.error('Minimum percent sequence identity must be' +
                            ' between 1.0 and 100.0: %2.2f' %
                            opts.min_percent_id)

    if not opts.template_fp and opts.alignment_method == 'pynast':
        option_parser.error(
            'PyNAST requires a template alignment to be passed via -t')

    input_seqs_filepath = opts.input_fasta_fp
    alignment_method = opts.alignment_method
    output_dir = opts.output_dir or alignment_method + '_aligned'
    create_dir(output_dir, fail_on_exist=False)

    # compute the minimum alignment length if a negative value was
    # provided (the default)
    min_length = opts.min_length
    if min_length < 0:
        min_length = compute_min_alignment_length(
            open(input_seqs_filepath, 'U'))

    fpath, ext = splitext(input_seqs_filepath)
    input_dir, fname = split(fpath)

    result_path = output_dir + '/' + fname + "_aligned.fasta"
    log_path = output_dir + '/' + fname + "_log.txt"
    failure_path = output_dir + '/' + fname + "_failures.fasta"

    if alignment_method in alignment_method_constructors:
        # try/except was causing problems here, so replacing with
        # an explicit check
        # define the aligner params
        aligner_constructor =\
            alignment_method_constructors[alignment_method]
        aligner_type = alignment_method
        params = {
            'min_len': min_length,
            'min_pct': opts.min_percent_id,
            'template_filepath': opts.template_fp,
            'blast_db': opts.blast_db,
            'pairwise_alignment_method': opts.pairwise_alignment_method
        }
        # build the aligner object
        aligner = aligner_constructor(params)
        # apply the aligner
        aligner(input_seqs_filepath,
                result_path=result_path,
                log_path=log_path,
                failure_path=failure_path)
    else:
        # define the aligner params
        aligner = CogentAligner({
            'Module':
            alignment_module_names.get(alignment_method, 'Unknown'),
            'Method':
            alignment_method
        })
        if alignment_method == "muscle":
            if opts.muscle_max_memory is not None:
                aligner.Params["-maxmb"] = str(opts.muscle_max_memory)
        # build the aligner
        aligner_type = 'Cogent'
        # apply the aligner
        aligner(result_path, seq_path=input_seqs_filepath, log_path=log_path)
Ejemplo n.º 7
0
 def _precommand_initiation(self, input_fp, output_dir, working_dir,
                            params):
     if params['min_length'] < 0:
         params['min_length'] = compute_min_alignment_length(
             open(input_fp, 'U'))
Ejemplo n.º 8
0
 def _precommand_initiation(
         self, input_fp, output_dir, working_dir, params):
     if params['min_length'] < 0:
         params['min_length'] = compute_min_alignment_length(
             open(input_fp, 'U'))