-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertChromName.py
More file actions
executable file
·64 lines (50 loc) · 1.8 KB
/
Copy pathconvertChromName.py
File metadata and controls
executable file
·64 lines (50 loc) · 1.8 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/home/mplace/anaconda3/bin/python
"""
@Program: convertChromName.py
@Purpose: Convert chromosome names in gff file.
Change chrI to ref|NC_
@Input: Fastq file, unzipped
@Dependencies: Python 3
@author: Mike Place
Example:
"""
import re
import sys
chromDict = { "chrI" : "ref|NC_001133|", "chrII" : "ref|NC_001134|", "chrIII" : "ref|NC_001135|",
"chrIV" : "ref|NC_001136|", "chrV" : "ref|NC_001137|", "chrVI" : "ref|NC_001138|",
"chrVII" : "ref|NC_001139|", "chrVIII" : "ref|NC_001140|", "chrIX" : "ref|NC_001141|",
"chrX" : "ref|NC_001142|", "chrXI" : "ref|NC_001143|", "chrXII" : "ref|NC_001144|",
"chrXIII" : "ref|NC_001145|", "chrXIV" : "ref|NC_001146|", "chrXV" : "ref|NC_001147|",
"chrXVI" : "ref|NC_001148|", "chrMito" : "ref|NC_001224|", "chrmt" : "ref|NC_001224|"
}
def main():
"""
main()
"""
# if no args print help
if len(sys.argv) == 1:
print("\n\tInput file required.")
print("\n")
print("\tconvertChromName.py <gff file>")
print("\tConverts chrI name in .gff file to ref|NC_001133| to match")
print("\tthe SGD reference fasta file naming conventions\n")
sys.exit(1)
else:
fastq = sys.argv[1]
with open(fastq) as f:
for line in f:
if line.startswith('#'):
line = line.rstrip()
print(line),
continue
else:
line = line.rstrip()
row = line.split('\t')
chrom = row[0]
if chrom in chromDict:
row[0]= chromDict[chrom]
print( "\t".join(row) )
else:
print( "\t".join(row) )
if __name__ == "__main__":
main()