import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
19680801)
np.random.seed(
= plt.subplots(2, 2)
fig, axs = ['RdBu_r', 'viridis']
cmaps for col in range(2):
for row in range(2):
= axs[row, col]
ax = ax.pcolormesh(np.random.random((20, 20)) * (col + 1),
pcm =cmaps[col])
cmap=axs[:, col], shrink=0.6)
fig.colorbar(pcm, ax plt.show()
Some graphics
Taken from matplotlib.org gallery.
Rosalind problems
Just some solutions to some basic Project Rosalind problems.
Complementing a Strand of DNA
Sample Input
AAAACCCGGT
Sample Output
ACCGGGTTTT
def reverse_complement(nuc_sequence):
"""
Returns the reverse complement of a nucleotide sequence.
>>> reverse_complement('ACGT')
'ACGT'
>>> reverse_complement('ATCGTGCTGCTGTCGTCAAGAC')
'GTCTTGACGACAGCAGCACGAT'
>>> reverse_complement('TGCTAGCATCGAGTCGATCGATATATTTAGCATCAGCATT')
'AATGCTGATGCTAAATATATCGATCGACTCGATGCTAGCA'
"""
= {
complements "A": "T",
"C": "G",
"G": "C",
"T": "A"
}= "".join([complements[s] for s in nuc_sequence[::-1]])
rev_seq return rev_seq
import doctest
globals(), verbose=True) doctest.run_docstring_examples(reverse_complement,
Finding tests in NoName
Trying:
reverse_complement('ACGT')
Expecting:
'ACGT'
ok
Trying:
reverse_complement('ATCGTGCTGCTGTCGTCAAGAC')
Expecting:
'GTCTTGACGACAGCAGCACGAT'
ok
Trying:
reverse_complement('TGCTAGCATCGAGTCGATCGATATATTTAGCATCAGCATT')
Expecting:
'AATGCTGATGCTAAATATATCGATCGACTCGATGCTAGCA'
ok
"Good!" if reverse_complement('AAAACCCGGT') == 'ACCGGGTTTT' else "Not good!"
‘Good!’