Created
May 23, 2013 07:19
-
-
Save Dubhead/5633254 to your computer and use it in GitHub Desktop.
A Python version gets a lot slower when str.count(I) is inhibited.
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
#!/usr/bin/python | |
def main(): | |
gcCount = 0 | |
atCount = 0 | |
with open("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa", "r") as f: | |
for line in f: | |
if not line.startswith('>'): | |
# gcCount += line.count('G') + line.count('C') | |
# atCount += line.count('A') + line.count('T') | |
for c in line: | |
if c == 'G' or c == 'C': | |
gcCount += 1 | |
elif c == 'A' or c == 'T': | |
atCount += 1 | |
print(gcCount * 100.0 / (gcCount + atCount)) | |
if __name__ == '__main__': | |
main() | |
# eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment