annotate SeqSero/libs/compare_and_change_two_fastq_id.py @ 4:ab0802d77891 draft default tip

Uploaded
author estrain
date Thu, 12 Sep 2019 06:46:00 -0400
parents c577b57b7c74
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
1 #!/usr/bin/env python
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
2
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
3 import os,sys
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
4 file1=sys.argv[1]
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
5 file2=sys.argv[2]
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
6
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
7
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
8 def compare_and_change_two_fastq_id(file1,file2):
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
9 a=os.popen("head "+file1).read().split("\n")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
10 b=os.popen("head "+file2).read().split("\n")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
11 for x in a:
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
12 if x.startswith("@"):
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
13 a_title=x.split(" ")[0]
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
14 for x in b:
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
15 if x.startswith("@"):
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
16 b_title=x.split(" ")[0]
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
17 if a_title==b_title:
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
18 pass
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
19 else:
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
20 print "changing the title of two seperated fastq files..."
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
21 print a_title,b_title
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
22 os.system("sed "+"-i 's/.1 / /g' "+file1)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
23 print "finished file1"
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
24 os.system("sed "+"-i 's/.2 / /g' "+file2)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
25 print "finished file2"
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
26
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
27 compare_and_change_two_fastq_id(file1,file2)