Codebase list fastaq / e83fffb
Imported Upstream version 3.11.0 Sascha Steinbiss 8 years ago
8 changed file(s) with 40 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
0 version = '3.10.1'
0 version = '3.11.0'
44 parser = argparse.ArgumentParser(
55 description = description,
66 usage = 'fastaq interleave <infile_1> <infile_2> <outfile>')
7 parser.add_argument('--suffix1', help='Suffix to add to all names from infile_1 (if suffix not already present)')
8 parser.add_argument('--suffix2', help='Suffix to add to all names from infile_2 (if suffix not already present)')
79 parser.add_argument('infile_1', help='Name of first input file')
810 parser.add_argument('infile_2', help='Name of second input file')
911 parser.add_argument('outfile', help='Name of output file of interleaved reads')
1012 options = parser.parse_args()
11 tasks.interleave(options.infile_1, options.infile_2, options.outfile)
13 tasks.interleave(
14 options.infile_1,
15 options.infile_2,
16 options.outfile,
17 suffix1=options.suffix1,
18 suffix2=options.suffix2
19 )
353353 utils.close(fout)
354354
355355
356 def interleave(infile_1, infile_2, outfile):
356 def interleave(infile_1, infile_2, outfile, suffix1=None, suffix2=None):
357 '''Makes interleaved file from two sequence files. If used, will append suffix1 onto end
358 of every sequence name in infile_1, unless it already ends with suffix1. Similar for sufffix2.'''
357359 seq_reader_1 = sequences.file_reader(infile_1)
358360 seq_reader_2 = sequences.file_reader(infile_2)
359361 f_out = utils.open_file_write(outfile)
364366 except:
365367 utils.close(f_out)
366368 raise Error('Error getting mate for sequence', seq_1.id, ' ... cannot continue')
369
370 if suffix1 is not None and not seq_1.id.endswith(suffix1):
371 seq_1.id += suffix1
372 if suffix2 is not None and not seq_2.id.endswith(suffix2):
373 seq_2.id += suffix2
367374
368375 print(seq_1, file=f_out)
369376 print(seq_2, file=f_out)
223223 tmp)
224224 self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_interleaved.fa'), tmp))
225225
226 tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_no_suffixes_1.fa'),
227 os.path.join(data_dir, 'sequences_test_deinterleaved_no_suffixes_2.fa'),
228 tmp, suffix1='/1', suffix2='/2')
229 self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_interleaved_with_suffixes.fa'), tmp))
230
226231 with self.assertRaises(tasks.Error):
227232 tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_bad_1.fa'),
228233 os.path.join(data_dir, 'sequences_test_deinterleaved_bad_2.fa'),
33
44 setup(
55 name='pyfastaq',
6 version='3.10.1',
6 version='3.11.0',
77 description='Script to manipulate FASTA and FASTQ files, plus API for developers',
88 packages = find_packages(),
99 author='Martin Hunt',