~ubuntu-branches/ubuntu/trusty/qiime/trusty

« back to all changes in this revision

Viewing changes to qiime/truncate_reverse_primer.py

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2013-06-17 18:28:26 UTC
  • mfrom: (9.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20130617182826-376az5ad080a0sfe
Tags: 1.7.0+dfsg-1
Upload preparations done for BioLinux to Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
__copyright__ = "Copyright 2011, The QIIME Project"
7
7
__credits__ = ["William Walters"]
8
8
__license__ = "GPL"
9
 
__version__ = "1.5.0"
 
9
__version__ = "1.7.0"
10
10
__maintainer__ = "William Walters"
11
11
__email__ = "William.A.Walters@colorado.edu"
12
12
__status__ = "Release"
24
24
    mapping_fp:  mapping filepath
25
25
    """
26
26
    hds, mapping_data, run_description, errors, warnings = \
27
 
        process_id_map(mapping_fp)
 
27
        process_id_map(mapping_fp, has_barcodes=False,
 
28
         disable_primer_check=True)
28
29
        
29
30
    if errors:
30
 
        raise ValueError,('Errors were found with mapping file, '+\
31
 
         'please run check_id_map.py to identify problems.')
 
31
        for curr_err in errors:
 
32
            if curr_err.startswith("Duplicate SampleID"):
 
33
                raise ValueError,('Errors were found with mapping file, '+\
 
34
                 'please run check_id_map.py to identify problems.')
32
35
         
33
36
    # create dict of dicts with SampleID:{each header:mapping data}
34
37
    
47
50
    for curr_id in id_map.keys():
48
51
        try:
49
52
            reverse_primers[curr_id] =\
50
 
             DNA.rc(id_map[curr_id]['ReversePrimer'])
 
53
             [DNA.rc(curr_rev_primer) for curr_rev_primer in\
 
54
             id_map[curr_id]['ReversePrimer'].split(',')]
51
55
        except KeyError:
52
56
            raise KeyError,("Reverse primer not found in mapping file, "+\
53
57
             "please include a 'ReversePrimer' column.")
 
58
 
54
59
             
55
60
    # Check for valid reverse primers
56
61
    # Will have been detected as warnings from mapping file
57
 
    for curr_warning in warnings:
58
 
        if curr_warning.startswith("reverse primer"):
 
62
    for curr_err in errors:
 
63
        if curr_err.startswith("Invalid DNA sequence detected"):
59
64
            raise ValueError,("Problems found with reverse primers, please "+\
60
65
             "check mapping file with check_id_map.py")
61
 
 
 
66
    
62
67
    return reverse_primers
63
68
    
64
69
def get_output_filepaths(output_dir,
115
120
            log_data['seqs_written'] += 1
116
121
            continue
117
122
        
118
 
        rev_primer_mm, rev_primer_index =\
119
 
         local_align_primer_seq(curr_rev_primer, seq)
 
123
        mm_tests = {}
 
124
        for rev_primer in curr_rev_primer: 
 
125
        
 
126
            rev_primer_mm, rev_primer_index =\
 
127
             local_align_primer_seq(rev_primer, seq)
 
128
             
 
129
            mm_tests[rev_primer_mm] = rev_primer_index
 
130
            
 
131
        rev_primer_mm = min(mm_tests.keys())
 
132
        rev_primer_index = mm_tests[rev_primer_mm]
120
133
         
121
134
        if rev_primer_mm > primer_mismatches:
122
135
            if truncate_option == "truncate_remove":