Created
October 7, 2016 12:49
-
-
Save Swarchal/9da1aeaa4b5a4e91feaae238f14c445e to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env python3 | |
from sys import argv | |
from math import factorial | |
def parse_fasta(in_file): | |
""" return sequence from single fasta """ | |
seqs = [line for line in open(in_file) if not line.startswith(">")] | |
return "".join(seqs).replace("\n", "") | |
def pmch(seq): | |
""" return number of perfect matchings of basepair edges in sequence """ | |
return factorial(seq.count("A")) * factorial(seq.count("C")) | |
def main(fasta_path): | |
sequence = parse_fasta(fasta_path) | |
return pmch(sequence) | |
if __name__ == "__main__": | |
print(main(argv[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment