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