In [1]:
%pylab inline
from __future__ import division
from collections import Counter
from Bio import SeqIO
from pyseqlogo.pyseqlogo import draw_logo
plt.rcParams['figure.dpi'] = 300
plt.rcParams['savefig.dpi'] = 300
In [2]:
!wget -c ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_27/gencode.v27.pc_translations.fa.gz
In [3]:
human_aa_fasta = './gencode.v27.pc_translations.fa.gz'
human_aa = Counter()
with open(human_aa_fasta) as f:
for record in SeqIO.parse(f, 'fasta'):
human_aa+=Counter(record.seq)
In [4]:
human_total = sum(list(human_aa.viewvalues()))
merry = ['M', 'E', 'R', 'R', 'Y']
christmas = ['C', 'H', 'R', 'I', 'S', 'T', 'M', 'A', 'S']
data_merry = [[(x, 200*float(human_aa[x])/human_total)] for x in merry]
data_christmas = [[(x, 200*float(human_aa[x])/human_total)] for x in christmas]
In [5]:
_, _ = draw_logo(data_merry,
coordinate_type='display',
data_type='bits',
yaxis='probability',
colorscheme='physiochemical',
fontfamily='Monospace')
plt.savefig('merry.png', dpi=300)
In [6]:
_, _ = draw_logo(data_christmas,
data_type='bits',
colorscheme='physiochemical',
yaxis='probability',
coordinate_type='display',
fontfamily='Monospace')
plt.savefig('christmas.png', dpi=300)
In [ ]: