comparison format_reago_input_files.py @ 0:13dd84cab09e draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/reago commit f5be73e67192909db96dfab214f4360eb41757a4
author bgruening
date Sat, 27 Apr 2024 17:59:57 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13dd84cab09e
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import argparse
5
6
7 def add_read_pair_num(input_filepath, output_filepath, read_pair_num):
8 to_add = "." + str(read_pair_num)
9 with open(input_filepath, "r") as input_file:
10 with open(output_filepath, "w") as output_file:
11 for line in input_file:
12 if line.startswith(">"):
13 split_line = line.split()
14 seq_id = split_line[0]
15 if seq_id.rfind(to_add) != (len(seq_id) - len(to_add)):
16 split_line[0] = seq_id + to_add
17 output_file.write(" ".join(split_line) + "\n")
18 else:
19 output_file.write(line)
20
21
22 if __name__ == "__main__":
23 parser = argparse.ArgumentParser()
24 parser.add_argument("--r1_input", required=True)
25 parser.add_argument("--r2_input", required=True)
26 parser.add_argument("--r1_output", required=True)
27 parser.add_argument("--r2_output", required=True)
28 args = parser.parse_args()
29
30 add_read_pair_num(args.r1_input, args.r1_output, 1)
31 add_read_pair_num(args.r2_input, args.r2_output, 2)