-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrecter.py
More file actions
executable file
·42 lines (36 loc) · 1.14 KB
/
Copy pathcorrecter.py
File metadata and controls
executable file
·42 lines (36 loc) · 1.14 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
import os, sys, math
import numpy as np
import time
from Bio import SeqIO
def trimmer(filename):
found = False
new_fasta = []
with open(filename) as inputfile:
for line in inputfile:
if line[0] == ">":
found = True
if found == True:
new_fasta.append(line)
return new_fasta
def writer(filename, new_fasta):
with open(filename, 'wb') as ffile:
for item in new_fasta:
print>>ffile, item
return
def quick_convert(fastaname):
SeqIO.convert(fastaname, "fasta", 'corrected_' + fastaname, "fasta")
os.system('mv corrected_' + fastaname + ' ' + fastaname)
return
def main():
t1 = time.time()
for filename in os.listdir('.'):
if filename.endswith(".fasta"):
filename_arr = filename.split(".")
new_fasta = trimmer(filename)
quick_convert(filename)
#writer(filename_arr[0], new_fasta)
#os.system('rm ' + filename)
#os.system('mv ' + filename_arr[0] + ' ' + filename)
print "Process took " + str(time.time()-t1) + " seconds."
if __name__ == "__main__":
main()