File: compare_and_change_two_fastq_id.py

package info (click to toggle)
seqsero 1.0.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,232 kB
  • sloc: python: 2,447; perl: 82; sh: 55; makefile: 7
file content (27 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/python3

import os,sys
file1=sys.argv[1]
file2=sys.argv[2]


def compare_and_change_two_fastq_id(file1,file2):
  a=os.popen("head "+file1).read().split("\n")
  b=os.popen("head "+file2).read().split("\n")
  for x in a:
    if x.startswith("@"):
      a_title=x.split(" ")[0]
  for x in b:
    if x.startswith("@"):
      b_title=x.split(" ")[0]
  if a_title==b_title:
    pass
  else:
    print("changing the title of two seperated fastq files...")
    print(a_title,b_title)
    os.system("sed "+"-i 's/.1 / /g' "+file1)
    print("finished file1")
    os.system("sed "+"-i 's/.2 / /g' "+file2)
    print("finished file2")

compare_and_change_two_fastq_id(file1,file2)