-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_tags.py
More file actions
executable file
·31 lines (25 loc) · 824 Bytes
/
fix_tags.py
File metadata and controls
executable file
·31 lines (25 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/env python
import sys
import random
from subprocess import call
if (sys.argv[1].split('.')[1] == "fastq") or (sys.argv[1].split('.')[1] == "fq"):
awk = "awk \'BEGIN{P=1}{if(P==1||P==2){gsub(/^[@]/,\">\");print}; if(P==4)P=0; P++}\' "
new_name = sys.argv[1].split('.')[0]+".fasta"
awk = awk + sys.argv[1] + " > " + new_name
call(awk,shell=True)
call(["rm",sys.argv[1]])
f = open(new_name,'r')
wf = open(sys.argv[1]+"_fixed",'w')
count = 120
for l in f:
if l[0] == '>':
wf.write(">m120322_062918_42162_c100279482550000001523008007041205_s1_p0/" + repr(random.randint(10,99)) + "/0_" + repr(count) +"\n")
else:
wf.write(l)
count = count + 1
name = f.name
tmp_name = wf.name
f.close()
wf.close()
call(["rm",name])
call(["mv",tmp_name,name])