#!/usr/bin/python
import re
# 1 # Read sequences and store them in a hash/dictionary
nonhuman = {}
id = ''
seq = ''
id_human = ''
humanseq = ''
for line in open('foxp2.fasta'):
line = line.rstrip()
if re.search('^>', line):
if id != '':
if not re.search('HUMAN', id):
nonhuman[id] = seq
else:
humanseq = seq
id_human = id
id = line.replace('>', '')
seq = ''
else:
seq += line
nonhuman[id] = seq # this assumes that we know that the
# final sequence read is non human
# 2 # Analyze the multiple alignment
for i in range(0, len(humanseq)):
unique = 1
for key in nonhuman.keys():
# check if the amino acid in the human sequence
# is the same as in the non-human sequence
if humanseq[i] == nonhuman[key][i]:
unique = 0
if unique:
print 'At position i'
aa = humanseq[i]
print id_human, '\t', aa
for key in nonhuman.keys():
aa = nonhuman[key][i]
print key, '\t', aa