-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepareRefInput.py
50 lines (36 loc) · 976 Bytes
/
prepareRefInput.py
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
###############################
## ##
## File: prepareRefInput.py ##
## Author: Dimitri Perrin ##
## ##
###############################
# Inputs:
# - one .fa file containing the whole reference genome (whith line breaks within chromosome)
#
# Outputs:
# - one .fa file with the whole genome (without those lines breaks)
from sys import argv
if len(argv)!=4:
print "\nUsage: "+argv[0]+" <dir> <input.fa> <output.fa>"
quit()
dir_ = argv[1]
in_ = dir_+argv[2]
out_ = dir_+argv[3]
inFile = open(in_,'r')
outFile = open(out_,'w')
nb=0
for line in inFile:
if line[0]==">":
print "'"+line[1:].rstrip().split(" ")[0]+"': "+str(nb)
if nb>0:
outFile.write("\n")
nb+=1
else:
outFile.write(line.rstrip())
inFile.close()
outFile.close()
#######################
## ##
## End of File ##
## ##
#######################