Created
October 8, 2012 18:31
-
-
Save gregpinero/3854089 to your computer and use it in GitHub Desktop.
Clean up a FASTA file that has unwanted characters in the description lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
infile = 'dsim-all-chromosome-r1.3.reassembly1.updated_wsu1.fasta' | |
ref_count = 0 | |
for line in open(infile,'r'): | |
if line.startswith('>'): | |
ref_count += 1 | |
print '>' + re.sub(r'[^0-9a-zA-Z_]', '', line)[:50] | |
else: | |
print line, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment