123456789101112131415161718192021222324 |
- def copySequenceClean(fromFile,projectFolderPath):
- # Copy sequence and clean heads
- f1 = open(fromFile,"r")
- f2 = open(os.path.join(projectFolderPath,"sequence.fasta"),"w+")
- f3 = open(os.path.join(projectFolderPath,"sequence_heads.txt"),"w+")
- line = f1.readline()
- counter = 0
- while line!="":
- if(line.startswith(">")):
- counter += 1
- f3.write(">seq"+str(counter)+"\t"+line)
- f2.write(">seq"+str(counter)+"\n")
- else:
- f2.write(line.upper())
- line = f1.readline()
- f1.close()
- f2.close()
- f3.close()
- # Create reverse complement Fasta file
- records = map(make_rc_record, SeqIO.parse(os.path.join(projectFolderPath,"sequence.fasta"), "fasta"))
- SeqIO.write(records, os.path.join(projectFolderPath,"sequence_rc.fasta"), "fasta")
- records = map(make_rc_record, SeqIO.parse(os.path.join(projectFolderPath,"sequence_rc.fasta"), "fasta"))
- SeqIO.write(records, os.path.join(projectFolderPath,"sequence.fasta"), "fasta")
-
|