Exemplo n.º 1
0
    def test_add_qiime_labels_valid_data(self):
        """ Tests overall script functionality """

        # With valid data should not raise any errors

        mapping_data = [
            '#SampleID	BarcodeSequence	LinkerPrimerSequence	InputFileNames	Description',
            'Sample1	AAAA	ACTG	%s	S1' % basename(self.fasta1_fp),
            'Sample2	TTTT	ACTG	%s	S2' % basename(self.fasta2_fp),
            'Sample3	CCCC	ACTG	%s	S3' % basename(self.fasta3_fp)
        ]

        filename_column = "InputFileNames"

        add_qiime_labels(mapping_data, self.input_dir, filename_column,
                         self.output_dir)

        output_fp = open(join(self.output_dir, "combined_seqs.fna"), "U")
        output_lines = [line.strip() for line in output_fp]

        expected_output_lines = [
            '>Sample1_0 label1 XXX', 'ACAGATTACGA', '>Sample1_1 label2 YYY',
            'ACATAAAATAGCCGGAG', '>Sample2_2 label3 ZZZ', 'AACGYAACGAGA',
            '>Sample2_3 label4', 'ACAGAGAGAGGGGAGA', '>Sample3_4 label5 ;LKJ',
            'ACAGGGATTTTTAT'
        ]

        self.assertEqual(output_lines, expected_output_lines)
    def test_add_qiime_labels_valid_data(self):
        """ Tests overall script functionality """

        # With valid data should not raise any errors

        mapping_data = [
            '#SampleID	BarcodeSequence	LinkerPrimerSequence	InputFileNames	Description',
            'Sample1	AAAA	ACTG	%s	S1' % basename(self.fasta1_fp),
            'Sample2	TTTT	ACTG	%s	S2' % basename(self.fasta2_fp),
            'Sample3	CCCC	ACTG	%s	S3' % basename(self.fasta3_fp)
        ]

        filename_column = "InputFileNames"

        add_qiime_labels(mapping_data, self.input_dir, filename_column,
                         self.output_dir)

        output_fp = open(join(self.output_dir, "combined_seqs.fna"), "U")
        output_lines = [line.strip() for line in output_fp]

        expected_output_lines = ['>Sample1_0 label1 XXX', 'ACAGATTACGA',
                                 '>Sample1_1 label2 YYY', 'ACATAAAATAGCCGGAG', '>Sample2_2 label3 ZZZ',
                                 'AACGYAACGAGA', '>Sample2_3 label4', 'ACAGAGAGAGGGGAGA',
                                 '>Sample3_4 label5 ;LKJ', 'ACAGGGATTTTTAT']

        self.assertEqual(output_lines, expected_output_lines)
Exemplo n.º 3
0
def main():
    option_parser, opts, args =\
     parse_command_line_parameters(**script_info)

    mapping_fp = opts.mapping_fp
    fasta_dir = opts.fasta_dir
    output_dir = opts.output_dir
    count_start = int(opts.count_start)
    filename_column = opts.filename_column

    # Check input filepaths
    try:
        test_mapping_f = open(mapping_fp, "U")
    except IOError:
        raise IOError,("Cannot open mapping filepath "+\
         "%s, please check filepath and permissions." % mapping_fp)

    if not isdir(fasta_dir):
        raise IOError, ("Specified fasta dir " +
                        "%s, does not exist" % fasta_dir)

    # Create output directory, check path/access to mapping file
    create_dir(output_dir)

    add_qiime_labels(open(mapping_fp, "U"), fasta_dir, filename_column,
                     output_dir, count_start)
Exemplo n.º 4
0
def main():
    option_parser, opts, args =\
     parse_command_line_parameters(**script_info)
      
    mapping_fp = opts.mapping_fp
    fasta_dir = opts.fasta_dir
    output_dir = opts.output_dir
    count_start = int(opts.count_start)
    filename_column = opts.filename_column

    # Check input filepaths
    try:
        test_mapping_f = open(mapping_fp, "U")
    except IOError:
        raise IOError,("Cannot open mapping filepath "+\
         "%s, please check filepath and permissions." % mapping_fp)
         
    if not isdir(fasta_dir):
        raise IOError,("Specified fasta dir "+
         "%s, does not exist" % fasta_dir)
    
    # Create output directory, check path/access to mapping file
    create_dir(output_dir)
    
    add_qiime_labels(open(mapping_fp, "U"), fasta_dir, filename_column,
     output_dir, count_start)
Exemplo n.º 5
0
 def test_add_qiime_labels_valid_data(self):
     """ Tests overall script functionality """
     
     # With valid data should not raise any errors
     
     mapping_data = ['Sample1\t%s' % basename(self.fasta1_fp),
                     'Sample2\t%s' % basename(self.fasta2_fp),
                     'Sample3\t%s' % basename(self.fasta3_fp)
                     ]
                     
     add_qiime_labels(mapping_data, self.input_dir, 
     self.output_dir)
     
     output_fp = open(join(self.output_dir, "combined_seqs.fna"), "U")
     output_lines = [line.strip() for line in output_fp]
     
     expected_output_lines = ['>Sample2_0 label3 ZZZ', 'AACGYAACGAGA',
      '>Sample2_1 label4', 'ACAGAGAGAGGGGAGA',
      '>Sample3_2 label5 ;LKJ', 'ACAGGGATTTTTAT',
      '>Sample1_3 label1 XXX', 'ACAGATTACGA',
      '>Sample1_4 label2 YYY', 'ACATAAAATAGCCGGAG']
      
     self.assertEqual(output_lines, expected_output_lines)
Exemplo n.º 6
0
    def test_add_qiime_labels_valid_data(self):
        """ Tests overall script functionality """

        # With valid data should not raise any errors

        mapping_data = [
            'Sample1\t%s' % basename(self.fasta1_fp),
            'Sample2\t%s' % basename(self.fasta2_fp),
            'Sample3\t%s' % basename(self.fasta3_fp)
        ]

        add_qiime_labels(mapping_data, self.input_dir, self.output_dir)

        output_fp = open(join(self.output_dir, "combined_seqs.fna"), "U")
        output_lines = [line.strip() for line in output_fp]

        expected_output_lines = [
            '>Sample2_0 label3 ZZZ', 'AACGYAACGAGA', '>Sample2_1 label4',
            'ACAGAGAGAGGGGAGA', '>Sample3_2 label5 ;LKJ', 'ACAGGGATTTTTAT',
            '>Sample1_3 label1 XXX', 'ACAGATTACGA', '>Sample1_4 label2 YYY',
            'ACATAAAATAGCCGGAG'
        ]

        self.assertEqual(output_lines, expected_output_lines)