Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #-*- coding:utf-8 -*-
- import re
- import sys
- AMINOS = {
- "A": "GC.",
- "R": "(?:CG.|AGA|AGG)",
- "N": "(?:AAT|AAC)",
- "D": "(?:GAT|GAC)",
- "C": "(?:TGT|TGC)",
- "Q": "(?:CAA|CAG)",
- "E": "(?:GAG|GAA)",
- "G": "GG.",
- "H": "(?:CAT|CAC)",
- "I": "(?:ATT|ATC|ATA)",
- "L": "(?:CT.|TTA|TTG)",
- "K": "(?:AAA|AAG)",
- "M": "ATG",
- "F": "(?:TTT|TTC)",
- "P": "CC.",
- "S": "(?:TC.|AGT|AGC)",
- "T": "AC.",
- "W": "TGG",
- "Y": "(?:TAT|TAC)",
- "V": "GT."
- }
- def inverse(st):
- M = {"C": "G", "G": "C", "A": "T", "T": "A"}
- return "".join(M[c] for c in st)
- with open(sys.argv[1]) as fp:
- pattern = "".join(AMINOS.get(c, "") for c in fp.read())
- regex = re.compile(pattern)
- with open(sys.argv[2]) as fp:
- sequence = "".join(line.strip() for line in fp)
- for match in regex.finditer(sequence):
- print "Match at %d to %d" % (match.start(), match.end())
- sequence = inverse(sequence)
- for match in regex.finditer(sequence):
- print "Match at inverse %d to %d" % (match.start(), match.end())
Add Comment
Please, Sign In to add comment