Imported Upstream version 3.11.0
Sascha Steinbiss
8 years ago
0 | |
version = '3.10.1'
|
|
0 |
version = '3.11.0'
|
4 | 4 |
parser = argparse.ArgumentParser(
|
5 | 5 |
description = description,
|
6 | 6 |
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)')
|
7 | 9 |
parser.add_argument('infile_1', help='Name of first input file')
|
8 | 10 |
parser.add_argument('infile_2', help='Name of second input file')
|
9 | 11 |
parser.add_argument('outfile', help='Name of output file of interleaved reads')
|
10 | 12 |
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 |
)
|
353 | 353 |
utils.close(fout)
|
354 | 354 |
|
355 | 355 |
|
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.'''
|
357 | 359 |
seq_reader_1 = sequences.file_reader(infile_1)
|
358 | 360 |
seq_reader_2 = sequences.file_reader(infile_2)
|
359 | 361 |
f_out = utils.open_file_write(outfile)
|
|
364 | 366 |
except:
|
365 | 367 |
utils.close(f_out)
|
366 | 368 |
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
|
367 | 374 |
|
368 | 375 |
print(seq_1, file=f_out)
|
369 | 376 |
print(seq_2, file=f_out)
|
|
0 |
>1/1
|
|
1 |
ACGTA
|
|
2 |
>1/2
|
|
3 |
ACGTA
|
|
4 |
>2/1
|
|
5 |
A
|
|
6 |
>2/2
|
|
7 |
C
|
223 | 223 |
tmp)
|
224 | 224 |
self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_interleaved.fa'), tmp))
|
225 | 225 |
|
|
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 |
|
226 | 231 |
with self.assertRaises(tasks.Error):
|
227 | 232 |
tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_bad_1.fa'),
|
228 | 233 |
os.path.join(data_dir, 'sequences_test_deinterleaved_bad_2.fa'),
|
3 | 3 |
|
4 | 4 |
setup(
|
5 | 5 |
name='pyfastaq',
|
6 | |
version='3.10.1',
|
|
6 |
version='3.11.0',
|
7 | 7 |
description='Script to manipulate FASTA and FASTQ files, plus API for developers',
|
8 | 8 |
packages = find_packages(),
|
9 | 9 |
author='Martin Hunt',
|