Mercurial > repos > rnateam > reago
comparison format_reago_input_files.py @ 0:715b263db9f3 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/reago commit 70bdf283c99eb20dfb2d13af0a460d36c47704fc
author | rnateam |
---|---|
date | Tue, 26 Jan 2016 08:17:20 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:715b263db9f3 |
---|---|
1 #!/usr/bin/env python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 import sys | |
5 import os | |
6 import argparse | |
7 import re | |
8 | |
9 def add_read_pair_num(input_filepath, output_filepath, read_pair_num): | |
10 to_add = '.' + str(read_pair_num) | |
11 with open(input_filepath,'r') as input_file: | |
12 with open(output_filepath,'w') as output_file: | |
13 for line in input_file: | |
14 if line.startswith('>'): | |
15 split_line = line.split() | |
16 seq_id = split_line[0] | |
17 if seq_id.rfind(to_add) != (len(seq_id)-len(to_add)): | |
18 split_line[0] = seq_id + to_add | |
19 output_file.write(' '.join(split_line) + '\n') | |
20 else: | |
21 output_file.write(line) | |
22 | |
23 if __name__ == '__main__': | |
24 parser = argparse.ArgumentParser() | |
25 parser.add_argument('--r1_input', required=True) | |
26 parser.add_argument('--r2_input', required=True) | |
27 parser.add_argument('--r1_output', required=True) | |
28 parser.add_argument('--r2_output', required=True) | |
29 args = parser.parse_args() | |
30 | |
31 add_read_pair_num(args.r1_input, args.r1_output, 1) | |
32 add_read_pair_num(args.r2_input, args.r2_output, 2) |