Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

1550 lines (1520 sloc) 99.92 kB
# Copyright 2008 by Bartek Wilczynski. All rights reserved.
# Adapted from test_Mymodule.py by Jeff Chang
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
import os
import unittest
from Bio import Motif
from Bio.Seq import Seq
class MotifTestsBasic(unittest.TestCase):
def setUp(self):
self.PFMin = open("Motif/SRF.pfm")
self.SITESin = open("Motif/Arnt.sites")
self.TFout = "Motif/tf.out"
self.FAout = "Motif/fa.out"
self.PFMout = "Motif/fa.out"
instance = Seq("ATATA")
instances = [instance]
self.m=Motif.Motif(instances=instances)
def tearDown(self):
self.PFMin.close()
self.SITESin.close()
if os.path.exists(self.TFout):
os.remove(self.TFout)
if os.path.exists(self.FAout):
os.remove(self.FAout)
def test_alignace_parsing(self):
"""Test if Motif can parse AlignAce output files.
"""
import warnings
from Bio import BiopythonExperimentalWarning
warnings.simplefilter('ignore', BiopythonExperimentalWarning)
from Bio.Alphabet import IUPAC
from Bio.Motif import AlignAce
handle = open("Motif/alignace.out")
record = AlignAce.read(handle)
handle.close()
self.assertEqual(record.version, "AlignACE 4.0 05/13/04")
self.assertEqual(record.command, "./AlignACE -i test.fa")
self.assertEqual(len(record.parameters), 7)
self.assertEqual(record.parameters['expect'], "10")
self.assertEqual(record.parameters['gcback'], "0.38")
self.assertEqual(record.parameters['minpass'], "200")
self.assertEqual(record.parameters['seed'], "1227623309")
self.assertEqual(record.parameters['numcols'], "10")
self.assertEqual(record.parameters['undersample'], "1")
self.assertEqual(record.parameters['oversample'], "1")
self.assertEqual(len(record.sequences), 10)
self.assertEqual(record.sequences[0], "SEQ1; M: CTCAATCGTAGA at 52")
self.assertEqual(record.sequences[1], "SEQ2; M: CTCAATCGTAGA at 172")
self.assertEqual(record.sequences[2], "SEQ3; M: CTCAATCGTAGA at 112")
self.assertEqual(record.sequences[3], "SEQ4; M: CTCAATCGTAGA at 173")
self.assertEqual(record.sequences[4], "SEQ5; M: CTCAATCGTAGA at 185")
self.assertEqual(record.sequences[5], "SEQ6; M: CTCAATCGTAGA at 105")
self.assertEqual(record.sequences[6], "SEQ7; M: CTCAATCGTAGA at 177")
self.assertEqual(record.sequences[7], "SEQ8; M: CTCAATCGTAGA at 172")
self.assertEqual(record.sequences[8], "SEQ9; M: CTCAATCGTAGA at 93")
self.assertEqual(record.sequences[9], "SEQ10; M: CTCAATCGTAGA at 3")
self.assertEqual(len(record.motifs), 16)
self.assertEqual(record.motifs[0].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[0].instances), 11)
self.assertEqual(str(record.motifs[0].instances[0]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[1]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[2]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[3]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[4]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[5]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[6]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[7]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[8]), "TCTACGATTGAG")
self.assertEqual(str(record.motifs[0].instances[9]), "TCAAAGATAGAG")
self.assertEqual(str(record.motifs[0].instances[10]), "TCTACGATTGAG")
self.assertEqual(record.motifs[0].mask, (1,1,0,1,1,1,1,1,0,1,1,1))
self.assertAlmostEqual(record.motifs[0].score, 57.9079)
self.assertEqual(record.motifs[1].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[1].instances), 22)
self.assertEqual(str(record.motifs[1].instances[0]), "GCGAAGGAAGCAGCGCGTGTG")
self.assertEqual(str(record.motifs[1].instances[1]), "GGCACCGCCTCTACGATTGAG")
self.assertEqual(str(record.motifs[1].instances[2]), "CAGAGCTTAGCATTGAACGCG")
self.assertEqual(str(record.motifs[1].instances[3]), "CTAATGAAAGCAATGAGAGTG")
self.assertEqual(str(record.motifs[1].instances[4]), "CTTGTGCCCTCTAAGCGTCCG")
self.assertEqual(str(record.motifs[1].instances[5]), "GAGCACGACGCTTTGTACCTG")
self.assertEqual(str(record.motifs[1].instances[6]), "CGGCACTTAGCAGCGTATCGT")
self.assertEqual(str(record.motifs[1].instances[7]), "CTGGTTTCATCTACGATTGAG")
self.assertEqual(str(record.motifs[1].instances[8]), "GGGCCAATAGCGGCGCCGGAG")
self.assertEqual(str(record.motifs[1].instances[9]), "GTGGAGTTATCTTAGTGCGCG")
self.assertEqual(str(record.motifs[1].instances[10]), "GAGAGGTTATCTACGATTGAG")
self.assertEqual(str(record.motifs[1].instances[11]), "CTGCTCCCCGCATACAGCGCG")
self.assertEqual(str(record.motifs[1].instances[12]), "CAGAACCGAGGTCCGGTACGG")
self.assertEqual(str(record.motifs[1].instances[13]), "GTGCCCCAAGCTTACCCAGGG")
self.assertEqual(str(record.motifs[1].instances[14]), "CGCCTCTGATCTACGATTGAG")
self.assertEqual(str(record.motifs[1].instances[15]), "GTGCTCATAGGGACGTCGCGG")
self.assertEqual(str(record.motifs[1].instances[16]), "CTGCCCCCCGCATAGTAGGGG")
self.assertEqual(str(record.motifs[1].instances[17]), "GTAAAGAAATCGATGTGCCAG")
self.assertEqual(str(record.motifs[1].instances[18]), "CACCTGCAATTGCTGGCAGCG")
self.assertEqual(str(record.motifs[1].instances[19]), "GGCGGGCCATCCCTGTATGAA")
self.assertEqual(str(record.motifs[1].instances[20]), "CTCCAGGTCGCATGGAGAGAG")
self.assertEqual(str(record.motifs[1].instances[21]), "CCTCGGATCGCTTGGGAAGAG")
self.assertEqual(record.motifs[1].mask, (1,0,1,1,0,1,0,0,1,1,1,0,0,0,1,0,0,0,1,0,1))
self.assertAlmostEqual(record.motifs[1].score, 19.6235)
self.assertEqual(record.motifs[2].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[2].instances), 18)
self.assertEqual(str(record.motifs[2].instances[0]), "GTGCGCGAAGGAAGCAGCGCG")
self.assertEqual(str(record.motifs[2].instances[1]), "CAGAGCTTAGCATTGAACGCG")
self.assertEqual(str(record.motifs[2].instances[2]), "GTGCCCGATGACCACCCGTCG")
self.assertEqual(str(record.motifs[2].instances[3]), "GCCCTCTAAGCGTCCGCGGAT")
self.assertEqual(str(record.motifs[2].instances[4]), "GAGCACGACGCTTTGTACCTG")
self.assertEqual(str(record.motifs[2].instances[5]), "CGGCACTTAGCAGCGTATCGT")
self.assertEqual(str(record.motifs[2].instances[6]), "GGGCCAATAGCGGCGCCGGAG")
self.assertEqual(str(record.motifs[2].instances[7]), "GCGCACTAAGATAACTCCACG")
self.assertEqual(str(record.motifs[2].instances[8]), "CGGCCCGTTGTCCAGCAGACG")
self.assertEqual(str(record.motifs[2].instances[9]), "CTGCTCCCCGCATACAGCGCG")
self.assertEqual(str(record.motifs[2].instances[10]), "GTGCCCCAAGCTTACCCAGGG")
self.assertEqual(str(record.motifs[2].instances[11]), "GTGCTCATAGGGACGTCGCGG")
self.assertEqual(str(record.motifs[2].instances[12]), "CTGCCCCCCGCATAGTAGGGG")
self.assertEqual(str(record.motifs[2].instances[13]), "CGCCGCCATGCGACGCAGAGG")
self.assertEqual(str(record.motifs[2].instances[14]), "AACCTCTAAGCATACTCTACG")
self.assertEqual(str(record.motifs[2].instances[15]), "GACCTGGAGGCTTAGACTTGG")
self.assertEqual(str(record.motifs[2].instances[16]), "GCGCTCTTCCCAAGCGATCCG")
self.assertEqual(str(record.motifs[2].instances[17]), "GGGCCGTCAGCTCTCAAGTCT")
self.assertEqual(record.motifs[2].mask, (1,0,1,1,0,1,0,0,0,1,1,0,0,0,1,0,1,0,0,1,1))
self.assertAlmostEqual(record.motifs[2].score, 19.1804)
self.assertEqual(record.motifs[3].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[3].instances), 16)
self.assertEqual(str(record.motifs[3].instances[0]), "GCCCCAAGCTTACCCAGGGAC")
self.assertEqual(str(record.motifs[3].instances[1]), "GCCGTCTGCTGGACAACGGGC")
self.assertEqual(str(record.motifs[3].instances[2]), "GCCGACGGGTGGTCATCGGGC")
self.assertEqual(str(record.motifs[3].instances[3]), "GCCAATAGCGGCGCCGGAGTC")
self.assertEqual(str(record.motifs[3].instances[4]), "GCCCCCCGCATAGTAGGGGGA")
self.assertEqual(str(record.motifs[3].instances[5]), "GCCCGTACCGGACCTCGGTTC")
self.assertEqual(str(record.motifs[3].instances[6]), "GCCTCATGTACCGGAAGGGAC")
self.assertEqual(str(record.motifs[3].instances[7]), "GACACGCGCCTGGGAGGGTTC")
self.assertEqual(str(record.motifs[3].instances[8]), "GCCTTTGGCCTTGGATGAGAA")
self.assertEqual(str(record.motifs[3].instances[9]), "GGCCCTCGGATCGCTTGGGAA")
self.assertEqual(str(record.motifs[3].instances[10]), "GCATGTTGGGAATCCGCGGAC")
self.assertEqual(str(record.motifs[3].instances[11]), "GACACGCGCTGTATGCGGGGA")
self.assertEqual(str(record.motifs[3].instances[12]), "GCCAGGTACAAAGCGTCGTGC")
self.assertEqual(str(record.motifs[3].instances[13]), "GCGATCAGCTTGTGGGCGTGC")
self.assertEqual(str(record.motifs[3].instances[14]), "GACAAATCGGATACTGGGGCA")
self.assertEqual(str(record.motifs[3].instances[15]), "GCACTTAGCAGCGTATCGTTA")
self.assertEqual(record.motifs[3].mask, (1,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,1,0,1))
self.assertAlmostEqual(record.motifs[3].score, 18.0097)
self.assertEqual(record.motifs[4].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[4].instances), 15)
self.assertEqual(str(record.motifs[4].instances[0]), "CGGCACAGAGCTT")
self.assertEqual(str(record.motifs[4].instances[1]), "ATCCGCGGACGCT")
self.assertEqual(str(record.motifs[4].instances[2]), "CGCCTGGGAGGGT")
self.assertEqual(str(record.motifs[4].instances[3]), "CGGAAGGGACGTT")
self.assertEqual(str(record.motifs[4].instances[4]), "ACACACAGACGGT")
self.assertEqual(str(record.motifs[4].instances[5]), "TGCCAGAGAGGTT")
self.assertEqual(str(record.motifs[4].instances[6]), "AGACTGAGACGTT")
self.assertEqual(str(record.motifs[4].instances[7]), "AATCGTAGAGGAT")
self.assertEqual(str(record.motifs[4].instances[8]), "CGTCTCGTAGGGT")
self.assertEqual(str(record.motifs[4].instances[9]), "CGTCGCGGAGGAT")
self.assertEqual(str(record.motifs[4].instances[10]), "CTTCTTAGACGCT")
self.assertEqual(str(record.motifs[4].instances[11]), "CGACGCAGAGGAT")
self.assertEqual(str(record.motifs[4].instances[12]), "ATGCTTAGAGGTT")
self.assertEqual(str(record.motifs[4].instances[13]), "AGACTTGGGCGAT")
self.assertEqual(str(record.motifs[4].instances[14]), "CGACCTGGAGGCT")
self.assertEqual(record.motifs[4].mask, (1,1,0,1,0,1,1,1,1,1,1,0,1))
self.assertAlmostEqual(record.motifs[4].score, 16.8287)
self.assertEqual(record.motifs[5].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[5].instances), 18)
self.assertEqual(str(record.motifs[5].instances[0]), "GTGCGCGAAGGAAGCAGCGCGTG")
self.assertEqual(str(record.motifs[5].instances[1]), "TTGAGCCGAGTAAAGGGCTGGTG")
self.assertEqual(str(record.motifs[5].instances[2]), "CAATGCTAAGCTCTGTGCCGACG")
self.assertEqual(str(record.motifs[5].instances[3]), "CAACTCTCTATGTAGTGCCCGAG")
self.assertEqual(str(record.motifs[5].instances[4]), "CGACGCTTTGTACCTGGCTTGCG")
self.assertEqual(str(record.motifs[5].instances[5]), "CGAGTCAATGACACGCGCCTGGG")
self.assertEqual(str(record.motifs[5].instances[6]), "CGATACGCTGCTAAGTGCCGTCC")
self.assertEqual(str(record.motifs[5].instances[7]), "CCGGGCCAATAGCGGCGCCGGAG")
self.assertEqual(str(record.motifs[5].instances[8]), "CCACGCTTCGACACGTGGTATAG")
self.assertEqual(str(record.motifs[5].instances[9]), "CCGAGCCTCATGTACCGGAAGGG")
self.assertEqual(str(record.motifs[5].instances[10]), "CTGCTCCCCGCATACAGCGCGTG")
self.assertEqual(str(record.motifs[5].instances[11]), "CCGAGGTCCGGTACGGGCAAGCC")
self.assertEqual(str(record.motifs[5].instances[12]), "GTGCTCATAGGGACGTCGCGGAG")
self.assertEqual(str(record.motifs[5].instances[13]), "CCCTACTATGCGGGGGGCAGGTC")
self.assertEqual(str(record.motifs[5].instances[14]), "GCCAGCAATTGCAGGTGGTCGTG")
self.assertEqual(str(record.motifs[5].instances[15]), "CTCTGCGTCGCATGGCGGCGTGG")
self.assertEqual(str(record.motifs[5].instances[16]), "GGAGGCTTAGACTTGGGCGATAC")
self.assertEqual(str(record.motifs[5].instances[17]), "GCATGGAGAGAGATCCGGAGGAG")
self.assertEqual(record.motifs[5].mask, (1,0,1,0,1,1,0,0,0,1,0,0,0,0,1,0,1,1,0,0,1,0,1))
self.assertAlmostEqual(record.motifs[5].score, 15.0441)
self.assertEqual(record.motifs[6].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[6].instances), 20)
self.assertEqual(str(record.motifs[6].instances[0]), "GCGCGTGTGTGTAAC")
self.assertEqual(str(record.motifs[6].instances[1]), "GCACAGAGCTTAGCA")
self.assertEqual(str(record.motifs[6].instances[2]), "GGTGGTCATCGGGCA")
self.assertEqual(str(record.motifs[6].instances[3]), "GCGCGTGTCATTGAC")
self.assertEqual(str(record.motifs[6].instances[4]), "GGACGGCACTTAGCA")
self.assertEqual(str(record.motifs[6].instances[5]), "GCGCGTCCCGGGCCA")
self.assertEqual(str(record.motifs[6].instances[6]), "GCTCGGCCCGTTGTC")
self.assertEqual(str(record.motifs[6].instances[7]), "GCGCGTGTCCTTTAA")
self.assertEqual(str(record.motifs[6].instances[8]), "GCTGATCGCTGCTCC")
self.assertEqual(str(record.motifs[6].instances[9]), "GCCCGTACCGGACCT")
self.assertEqual(str(record.motifs[6].instances[10]), "GGACGTCGCGGAGGA")
self.assertEqual(str(record.motifs[6].instances[11]), "GCGGGGGGCAGGTCA")
self.assertEqual(str(record.motifs[6].instances[12]), "GGACGTACTGGCACA")
self.assertEqual(str(record.motifs[6].instances[13]), "GCAGGTGGTCGTGCA")
self.assertEqual(str(record.motifs[6].instances[14]), "GCGCATACCTTAACA")
self.assertEqual(str(record.motifs[6].instances[15]), "GCACGGGACTTCAAC")
self.assertEqual(str(record.motifs[6].instances[16]), "GCACGTAGCTGGTAA")
self.assertEqual(str(record.motifs[6].instances[17]), "GCTCGTCTATGGTCA")
self.assertEqual(str(record.motifs[6].instances[18]), "GCGCATGCTGGATCC")
self.assertEqual(str(record.motifs[6].instances[19]), "GGCCGTCAGCTCTCA")
self.assertEqual(record.motifs[6].mask, (1,1,0,1,1,1,1,0,1,0,1,0,0,1,1))
self.assertAlmostEqual(record.motifs[6].score, 13.3145)
self.assertEqual(record.motifs[7].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[7].instances), 20)
self.assertEqual(str(record.motifs[7].instances[0]), "GAACCGAGGTCCGGTACGGGC")
self.assertEqual(str(record.motifs[7].instances[1]), "GCCCCCCGCATAGTAGGGGGA")
self.assertEqual(str(record.motifs[7].instances[2]), "GTCCCTGGGTAAGCTTGGGGC")
self.assertEqual(str(record.motifs[7].instances[3]), "ACTCCACGCTTCGACACGTGG")
self.assertEqual(str(record.motifs[7].instances[4]), "ATCCTCTGCGTCGCATGGCGG")
self.assertEqual(str(record.motifs[7].instances[5]), "GTTCAATGCTAAGCTCTGTGC")
self.assertEqual(str(record.motifs[7].instances[6]), "GCTCATAGGGACGTCGCGGAG")
self.assertEqual(str(record.motifs[7].instances[7]), "GTCCCGGGCCAATAGCGGCGC")
self.assertEqual(str(record.motifs[7].instances[8]), "GCACTTAGCAGCGTATCGTTA")
self.assertEqual(str(record.motifs[7].instances[9]), "GGCCCTCGGATCGCTTGGGAA")
self.assertEqual(str(record.motifs[7].instances[10]), "CTGCTGGACAACGGGCCGAGC")
self.assertEqual(str(record.motifs[7].instances[11]), "GGGCACTACATAGAGAGTTGC")
self.assertEqual(str(record.motifs[7].instances[12]), "AGCCTCCAGGTCGCATGGAGA")
self.assertEqual(str(record.motifs[7].instances[13]), "AATCGTAGATCAGAGGCGAGA")
self.assertEqual(str(record.motifs[7].instances[14]), "GAACTCCACTAAGACTTGAGA")
self.assertEqual(str(record.motifs[7].instances[15]), "GAGCAGCGATCAGCTTGTGGG")
self.assertEqual(str(record.motifs[7].instances[16]), "GCCAGGTACAAAGCGTCGTGC")
self.assertEqual(str(record.motifs[7].instances[17]), "AGTCAATGACACGCGCCTGGG")
self.assertEqual(str(record.motifs[7].instances[18]), "GGTCATGGAATCTTATGTAGC")
self.assertEqual(str(record.motifs[7].instances[19]), "GTAGATAACAGAGGTCGGGGG")
self.assertEqual(record.motifs[7].mask, (1,0,0,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,1,1))
self.assertAlmostEqual(record.motifs[7].score, 11.6098)
self.assertEqual(record.motifs[8].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[8].instances), 14)
self.assertEqual(str(record.motifs[8].instances[0]), "CCGAGTAAAGGGCTG")
self.assertEqual(str(record.motifs[8].instances[1]), "GTGGTCATCGGGCAC")
self.assertEqual(str(record.motifs[8].instances[2]), "GATAACAGAGGTCGG")
self.assertEqual(str(record.motifs[8].instances[3]), "CGGCGCCGGAGTCTG")
self.assertEqual(str(record.motifs[8].instances[4]), "GCGCGTCCCGGGCCA")
self.assertEqual(str(record.motifs[8].instances[5]), "CTGGACAACGGGCCG")
self.assertEqual(str(record.motifs[8].instances[6]), "CGGATACTGGGGCAG")
self.assertEqual(str(record.motifs[8].instances[7]), "GGGAGCAGCGATCAG")
self.assertEqual(str(record.motifs[8].instances[8]), "CAGAACCGAGGTCCG")
self.assertEqual(str(record.motifs[8].instances[9]), "GGGTCCCTGGGTAAG")
self.assertEqual(str(record.motifs[8].instances[10]), "GTGCTCATAGGGACG")
self.assertEqual(str(record.motifs[8].instances[11]), "GAGATCCGGAGGAGG")
self.assertEqual(str(record.motifs[8].instances[12]), "GCGATCCGAGGGCCG")
self.assertEqual(str(record.motifs[8].instances[13]), "GAGTTCACATGGCTG")
self.assertEqual(record.motifs[8].mask, (1,0,1,0,0,1,1,0,1,1,1,1,1,0,1))
self.assertAlmostEqual(record.motifs[8].score, 11.2943)
self.assertEqual(record.motifs[9].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[9].instances), 18)
self.assertEqual(str(record.motifs[9].instances[0]), "TAGAGGCGGTG")
self.assertEqual(str(record.motifs[9].instances[1]), "GCTAAGCTCTG")
self.assertEqual(str(record.motifs[9].instances[2]), "TGGAAGCAGTG")
self.assertEqual(str(record.motifs[9].instances[3]), "GCGAGGCTGTG")
self.assertEqual(str(record.motifs[9].instances[4]), "ACGACGCTTTG")
self.assertEqual(str(record.motifs[9].instances[5]), "GGGACGCGCAC")
self.assertEqual(str(record.motifs[9].instances[6]), "TCGAAGCGTGG")
self.assertEqual(str(record.motifs[9].instances[7]), "TGTATGCGGGG")
self.assertEqual(str(record.motifs[9].instances[8]), "GGTAAGCTTGG")
self.assertEqual(str(record.motifs[9].instances[9]), "TGTACGCTGGG")
self.assertEqual(str(record.motifs[9].instances[10]), "ACTATGCGGGG")
self.assertEqual(str(record.motifs[9].instances[11]), "GGTATGCGCTG")
self.assertEqual(str(record.motifs[9].instances[12]), "GGTACCCGGAG")
self.assertEqual(str(record.motifs[9].instances[13]), "GCGACGCAGAG")
self.assertEqual(str(record.motifs[9].instances[14]), "TGGCGGCGTGG")
self.assertEqual(str(record.motifs[9].instances[15]), "TCTAGGCGGGC")
self.assertEqual(str(record.motifs[9].instances[16]), "AGTATGCTTAG")
self.assertEqual(str(record.motifs[9].instances[17]), "TGGAGGCTTAG")
self.assertEqual(record.motifs[9].mask, (1,1,1,1,0,1,1,1,1,1,1))
self.assertAlmostEqual(record.motifs[9].score, 9.7924)
self.assertEqual(record.motifs[10].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[10].instances), 13)
self.assertEqual(str(record.motifs[10].instances[0]), "GCACAGAGCTTAGCATTGAAC")
self.assertEqual(str(record.motifs[10].instances[1]), "GTCCGCGGATTCCCAACATGC")
self.assertEqual(str(record.motifs[10].instances[2]), "ATACACAGCCTCGCAAGCCAG")
self.assertEqual(str(record.motifs[10].instances[3]), "GGCCCGGGACGCGCACTAAGA")
self.assertEqual(str(record.motifs[10].instances[4]), "GCCCGTTGTCCAGCAGACGGC")
self.assertEqual(str(record.motifs[10].instances[5]), "GAGCAGCGATCAGCTTGTGGG")
self.assertEqual(str(record.motifs[10].instances[6]), "GAACCGAGGTCCGGTACGGGC")
self.assertEqual(str(record.motifs[10].instances[7]), "GTCCCTGGGTAAGCTTGGGGC")
self.assertEqual(str(record.motifs[10].instances[8]), "GACCTGCCCCCCGCATAGTAG")
self.assertEqual(str(record.motifs[10].instances[9]), "AACCAGCGCATACCTTAACAG")
self.assertEqual(str(record.motifs[10].instances[10]), "ATCCTCTGCGTCGCATGGCGG")
self.assertEqual(str(record.motifs[10].instances[11]), "GACCATAGACGAGCATCAAAG")
self.assertEqual(str(record.motifs[10].instances[12]), "GGCCCTCGGATCGCTTGGGAA")
self.assertEqual(record.motifs[10].mask, (1,0,1,1,0,0,0,1,0,0,0,1,1,1,1,0,0,0,0,1,1))
self.assertAlmostEqual(record.motifs[10].score, 9.01393)
self.assertEqual(record.motifs[11].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[11].instances), 16)
self.assertEqual(str(record.motifs[11].instances[0]), "GCCGTCCGTC")
self.assertEqual(str(record.motifs[11].instances[1]), "GGCGTGCGCG")
self.assertEqual(str(record.motifs[11].instances[2]), "GGCGCGTGTC")
self.assertEqual(str(record.motifs[11].instances[3]), "AGCGCGTGTG")
self.assertEqual(str(record.motifs[11].instances[4]), "GCGGTGCGTG")
self.assertEqual(str(record.motifs[11].instances[5]), "AGCGCGTGTC")
self.assertEqual(str(record.motifs[11].instances[6]), "AGCGTCCGCG")
self.assertEqual(str(record.motifs[11].instances[7]), "ACCGTCTGTG")
self.assertEqual(str(record.motifs[11].instances[8]), "GCCATGCGAC")
self.assertEqual(str(record.motifs[11].instances[9]), "ACCACCCGTC")
self.assertEqual(str(record.motifs[11].instances[10]), "GGCGCCGGAG")
self.assertEqual(str(record.motifs[11].instances[11]), "ACCACGTGTC")
self.assertEqual(str(record.motifs[11].instances[12]), "GGCTTGCGAG")
self.assertEqual(str(record.motifs[11].instances[13]), "GCGATCCGAG")
self.assertEqual(str(record.motifs[11].instances[14]), "AGTGCGCGTC")
self.assertEqual(str(record.motifs[11].instances[15]), "AGTGCCCGAG")
self.assertEqual(record.motifs[11].mask, (1,1,1,1,1,1,1,1,1,1))
self.assertAlmostEqual(record.motifs[11].score, 7.51121)
self.assertEqual(record.motifs[12].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[12].instances), 16)
self.assertEqual(str(record.motifs[12].instances[0]), "GCCGACGGGTGGTCATCGGG")
self.assertEqual(str(record.motifs[12].instances[1]), "GCACGACGCTTTGTACCTGG")
self.assertEqual(str(record.motifs[12].instances[2]), "CCTGGGAGGGTTCAATAACG")
self.assertEqual(str(record.motifs[12].instances[3]), "GCGCGTCCCGGGCCAATAGC")
self.assertEqual(str(record.motifs[12].instances[4]), "GCCGTCTGCTGGACAACGGG")
self.assertEqual(str(record.motifs[12].instances[5]), "GTCCCTTCCGGTACATGAGG")
self.assertEqual(str(record.motifs[12].instances[6]), "GCTGCTCCCCGCATACAGCG")
self.assertEqual(str(record.motifs[12].instances[7]), "GCCCCAAGCTTACCCAGGGA")
self.assertEqual(str(record.motifs[12].instances[8]), "ACCGGCTGACGCTAATACGG")
self.assertEqual(str(record.motifs[12].instances[9]), "GCGGGGGGCAGGTCATTACA")
self.assertEqual(str(record.motifs[12].instances[10]), "GCTGGCAGCGTCTAAGAAGG")
self.assertEqual(str(record.motifs[12].instances[11]), "GCAGGTGGTCGTGCAATACG")
self.assertEqual(str(record.motifs[12].instances[12]), "GCTGGTTGAAGTCCCGTGCG")
self.assertEqual(str(record.motifs[12].instances[13]), "GCACGTAGCTGGTAAATAGG")
self.assertEqual(str(record.motifs[12].instances[14]), "GCGGCGTGGATTTCATACAG")
self.assertEqual(str(record.motifs[12].instances[15]), "CCTGGAGGCTTAGACTTGGG")
self.assertEqual(record.motifs[12].mask, (1,1,0,1,1,0,0,1,1,0,1,0,0,0,1,0,0,0,1,1))
self.assertAlmostEqual(record.motifs[12].score, 5.63667)
self.assertEqual(record.motifs[13].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[13].instances), 15)
self.assertEqual(str(record.motifs[13].instances[0]), "GCCGACGGGTGGTCATCGGG")
self.assertEqual(str(record.motifs[13].instances[1]), "ATCCGCGGACGCTTAGAGGG")
self.assertEqual(str(record.motifs[13].instances[2]), "ACGCTTTGTACCTGGCTTGC")
self.assertEqual(str(record.motifs[13].instances[3]), "ACGGACGGCACTTAGCAGCG")
self.assertEqual(str(record.motifs[13].instances[4]), "GCCGTCTGCTGGACAACGGG")
self.assertEqual(str(record.motifs[13].instances[5]), "ACACACAGACGGTTGAAAGG")
self.assertEqual(str(record.motifs[13].instances[6]), "GCCGATAGTGCTTAAGTTCG")
self.assertEqual(str(record.motifs[13].instances[7]), "CTTGCCCGTACCGGACCTCG")
self.assertEqual(str(record.motifs[13].instances[8]), "ACCGGCTGACGCTAATACGG")
self.assertEqual(str(record.motifs[13].instances[9]), "GCCCCCCGCATAGTAGGGGG")
self.assertEqual(str(record.motifs[13].instances[10]), "GCTGGCAGCGTCTAAGAAGG")
self.assertEqual(str(record.motifs[13].instances[11]), "GCAGGTGGTCGTGCAATACG")
self.assertEqual(str(record.motifs[13].instances[12]), "ACGCACGGGACTTCAACCAG")
self.assertEqual(str(record.motifs[13].instances[13]), "GCACGTAGCTGGTAAATAGG")
self.assertEqual(str(record.motifs[13].instances[14]), "ATCCTCTGCGTCGCATGGCG")
self.assertEqual(record.motifs[13].mask, (1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,0,1,1))
self.assertAlmostEqual(record.motifs[13].score, 3.89842)
self.assertEqual(record.motifs[14].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[14].instances), 14)
self.assertEqual(str(record.motifs[14].instances[0]), "GAGGCTGTGTAT")
self.assertEqual(str(record.motifs[14].instances[1]), "GAGGTCGGGGGT")
self.assertEqual(str(record.motifs[14].instances[2]), "GACGGACGGCAC")
self.assertEqual(str(record.motifs[14].instances[3]), "TTGGCCCGGGAC")
self.assertEqual(str(record.motifs[14].instances[4]), "GAGGCTCGGCCC")
self.assertEqual(str(record.motifs[14].instances[5]), "CACGCGCTGTAT")
self.assertEqual(str(record.motifs[14].instances[6]), "TAGGCCAGGTAT")
self.assertEqual(str(record.motifs[14].instances[7]), "GAGGTCCGGTAC")
self.assertEqual(str(record.motifs[14].instances[8]), "TACGCTGGGGAT")
self.assertEqual(str(record.motifs[14].instances[9]), "GTCGCGGAGGAT")
self.assertEqual(str(record.motifs[14].instances[10]), "TACGCACGGGAC")
self.assertEqual(str(record.motifs[14].instances[11]), "TACTCCGGGTAC")
self.assertEqual(str(record.motifs[14].instances[12]), "GACGCAGAGGAT")
self.assertEqual(str(record.motifs[14].instances[13]), "TAGGCGGGCCAT")
self.assertEqual(record.motifs[14].mask, (1,1,1,1,1,0,1,1,1,0,1,1))
self.assertAlmostEqual(record.motifs[14].score, 3.33444)
self.assertEqual(record.motifs[15].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs[15].instances), 21)
self.assertEqual(str(record.motifs[15].instances[0]), "CGGCTCAATCGTAGAGGC")
self.assertEqual(str(record.motifs[15].instances[1]), "CGACGGGTGGTCATCGGG")
self.assertEqual(str(record.motifs[15].instances[2]), "CGCTTAGAGGGCACAAGC")
self.assertEqual(str(record.motifs[15].instances[3]), "TGACACGCGCCTGGGAGG")
self.assertEqual(str(record.motifs[15].instances[4]), "CGATACGCTGCTAAGTGC")
self.assertEqual(str(record.motifs[15].instances[5]), "CGTCCCGGGCCAATAGCG")
self.assertEqual(str(record.motifs[15].instances[6]), "CCACGCTTCGACACGTGG")
self.assertEqual(str(record.motifs[15].instances[7]), "CGTCTGCTGGACAACGGG")
self.assertEqual(str(record.motifs[15].instances[8]), "ACACAGACGGTTGAAAGG")
self.assertEqual(str(record.motifs[15].instances[9]), "TGCTCCCCGCATACAGCG")
self.assertEqual(str(record.motifs[15].instances[10]), "TGAGGCTTGCCCGTACCG")
self.assertEqual(str(record.motifs[15].instances[11]), "TGCCCCAAGCTTACCCAG")
self.assertEqual(str(record.motifs[15].instances[12]), "CGGCTGACGCTAATACGG")
self.assertEqual(str(record.motifs[15].instances[13]), "CGCGACGTCCCTATGAGC")
self.assertEqual(str(record.motifs[15].instances[14]), "TGCCCCCCGCATAGTAGG")
self.assertEqual(str(record.motifs[15].instances[15]), "CGTTGCCTTCTTAGACGC")
self.assertEqual(str(record.motifs[15].instances[16]), "TGACTCAATCGTAGACCC")
self.assertEqual(str(record.motifs[15].instances[17]), "AGTCCCGTGCGTATGTGG")
self.assertEqual(str(record.motifs[15].instances[18]), "AGGCTCGCACGTAGCTGG")
self.assertEqual(str(record.motifs[15].instances[19]), "CCACGCCGCCATGCGACG")
self.assertEqual(str(record.motifs[15].instances[20]), "AGCCTCCAGGTCGCATGG")
self.assertEqual(record.motifs[15].mask, (1,1,0,1,0,1,0,0,1,1,0,1,1,0,0,0,1,1))
self.assertAlmostEqual(record.motifs[15].score, 1.0395)
def test_pfm_parsing(self):
"""Test to be sure that Motif can parse pfm files.
"""
import warnings
from Bio import BiopythonExperimentalWarning
warnings.simplefilter('ignore', BiopythonExperimentalWarning)
m = Motif.read(self.PFMin,"pfm")
self.assertEqual(m.length, 12)
def test_sites_parsing(self):
"""Test to be sure that Motif can parse sites files.
"""
import warnings
from Bio import BiopythonExperimentalWarning
warnings.simplefilter('ignore', BiopythonExperimentalWarning)
m = Motif.read(self.SITESin,"sites")
self.assertEqual(m.length, 6)
def test_FAoutput(self):
"""Ensure that we can write proper FASTA output files.
"""
output_handle = open(self.FAout, "w")
output_handle.write(self.m.format("fasta"))
output_handle.close()
def test_TFoutput(self):
"""Ensure that we can write proper TransFac output files.
"""
output_handle = open(self.TFout, "w")
output_handle.write(self.m.format("transfac"))
output_handle.close()
def test_pfm_output(self):
"""Ensure that we can write proper pfm output files.
"""
output_handle = open(self.PFMout, "w")
output_handle.write(self.m.format("jaspar-pfm"))
output_handle.close()
class TestMEME(unittest.TestCase):
def test_meme_parser_1(self):
"""Test if Motif can parse MEME output files (first test)
"""
from Bio.Alphabet import IUPAC
from Bio.Motif import MEME
handle = open("Motif/meme.out")
record = MEME.read(handle)
self.assertEqual(record.version, '3.5.7')
self.assertEqual(record.datafile, 'test.fa')
self.assertEqual(record.alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.sequences), 10)
self.assertEqual(record.sequences[0], 'SEQ1;')
self.assertEqual(record.sequences[1], 'SEQ2;')
self.assertEqual(record.sequences[2], 'SEQ3;')
self.assertEqual(record.sequences[3], 'SEQ4;')
self.assertEqual(record.sequences[4], 'SEQ5;')
self.assertEqual(record.sequences[5], 'SEQ6;')
self.assertEqual(record.sequences[6], 'SEQ7;')
self.assertEqual(record.sequences[7], 'SEQ8;')
self.assertEqual(record.sequences[8], 'SEQ9;')
self.assertEqual(record.sequences[9], 'SEQ10;')
self.assertEqual(record.command, 'meme test.fa -dna -w 10 -dir /home/bartek/MetaMotif/meme')
self.assertEqual(len(record.motifs), 1)
motif = record.motifs[0]
self.assertEqual(motif.num_occurrences, 10)
self.assertAlmostEqual(motif.evalue, 1.1e-22)
self.assertEqual(motif.alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.name, "Motif 1")
self.assertEqual(len(motif.instances), 10)
self.assertAlmostEqual(motif.instances[0].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[1].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[2].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[3].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[4].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[5].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[6].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[7].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[8].pvalue, 8.71e-07)
self.assertAlmostEqual(motif.instances[9].pvalue, 8.71e-07)
self.assertEqual(motif.instances[0].sequence_name, 'SEQ10;')
self.assertEqual(motif.instances[1].sequence_name, 'SEQ9;')
self.assertEqual(motif.instances[2].sequence_name, 'SEQ8;')
self.assertEqual(motif.instances[3].sequence_name, 'SEQ7;')
self.assertEqual(motif.instances[4].sequence_name, 'SEQ6;')
self.assertEqual(motif.instances[5].sequence_name, 'SEQ5;')
self.assertEqual(motif.instances[6].sequence_name, 'SEQ4;')
self.assertEqual(motif.instances[7].sequence_name, 'SEQ3;')
self.assertEqual(motif.instances[8].sequence_name, 'SEQ2;')
self.assertEqual(motif.instances[9].sequence_name, 'SEQ1;')
self.assertEqual(motif.instances[0].start, 3)
self.assertEqual(motif.instances[1].start, 93)
self.assertEqual(motif.instances[2].start, 172)
self.assertEqual(motif.instances[3].start, 177)
self.assertEqual(motif.instances[4].start, 105)
self.assertEqual(motif.instances[5].start, 185)
self.assertEqual(motif.instances[6].start, 173)
self.assertEqual(motif.instances[7].start, 112)
self.assertEqual(motif.instances[8].start, 172)
self.assertEqual(motif.instances[9].start, 52)
self.assertEqual(motif.instances[0].strand, '+')
self.assertEqual(motif.instances[1].strand, '+')
self.assertEqual(motif.instances[2].strand, '+')
self.assertEqual(motif.instances[3].strand, '+')
self.assertEqual(motif.instances[4].strand, '+')
self.assertEqual(motif.instances[5].strand, '+')
self.assertEqual(motif.instances[6].strand, '+')
self.assertEqual(motif.instances[7].strand, '+')
self.assertEqual(motif.instances[8].strand, '+')
self.assertEqual(motif.instances[9].strand, '+')
self.assertEqual(motif.instances[0].length, 10)
self.assertEqual(motif.instances[1].length, 10)
self.assertEqual(motif.instances[2].length, 10)
self.assertEqual(motif.instances[3].length, 10)
self.assertEqual(motif.instances[4].length, 10)
self.assertEqual(motif.instances[5].length, 10)
self.assertEqual(motif.instances[6].length, 10)
self.assertEqual(motif.instances[7].length, 10)
self.assertEqual(motif.instances[8].length, 10)
self.assertEqual(motif.instances[9].length, 10)
self.assertEqual(motif.instances[0].motif_name, 'Motif 1')
self.assertEqual(motif.instances[1].motif_name, 'Motif 1')
self.assertEqual(motif.instances[2].motif_name, 'Motif 1')
self.assertEqual(motif.instances[3].motif_name, 'Motif 1')
self.assertEqual(motif.instances[4].motif_name, 'Motif 1')
self.assertEqual(motif.instances[5].motif_name, 'Motif 1')
self.assertEqual(motif.instances[6].motif_name, 'Motif 1')
self.assertEqual(motif.instances[7].motif_name, 'Motif 1')
self.assertEqual(motif.instances[8].motif_name, 'Motif 1')
self.assertEqual(motif.instances[9].motif_name, 'Motif 1')
self.assertEqual(motif.instances[0].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[1].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[2].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[3].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[4].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[5].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[6].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[7].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[8].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.instances[9].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(str(motif.instances[0]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[1]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[2]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[3]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[4]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[5]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[6]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[7]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[8]), "CTCAATCGTA")
self.assertEqual(str(motif.instances[9]), "CTCAATCGTA")
handle.close()
def test_meme_parser_2(self):
"""Test if Motif can parse MEME output files (second test)
"""
from Bio.Alphabet import IUPAC
from Bio.Motif import MEME
handle = open("Motif/meme.dna.oops.txt")
record = MEME.read(handle)
self.assertEqual(record.version, '3.0')
self.assertEqual(record.datafile, 'INO_up800.s')
self.assertEqual(record.alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.sequences), 7)
self.assertEqual(record.sequences[0], 'CHO1')
self.assertEqual(record.sequences[1], 'CHO2')
self.assertEqual(record.sequences[2], 'FAS1')
self.assertEqual(record.sequences[3], 'FAS2')
self.assertEqual(record.sequences[4], 'ACC1')
self.assertEqual(record.sequences[5], 'INO1')
self.assertEqual(record.sequences[6], 'OPI3')
self.assertEqual(record.command, 'meme -mod oops -dna -revcomp -nmotifs 2 -bfile yeast.nc.6.freq INO_up800.s')
self.assertEqual(len(record.motifs), 2)
motif = record.motifs[0]
self.assertEqual(motif.num_occurrences, 7)
self.assertAlmostEqual(motif.evalue, 0.2)
self.assertEqual(motif.alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.name, "Motif 1")
self.assertEqual(len(motif.instances), 7)
self.assertAlmostEqual(motif.instances[0].pvalue, 1.85e-08)
self.assertAlmostEqual(motif.instances[1].pvalue, 1.85e-08)
self.assertAlmostEqual(motif.instances[2].pvalue, 1.52e-07)
self.assertAlmostEqual(motif.instances[3].pvalue, 2.52e-07)
self.assertAlmostEqual(motif.instances[4].pvalue, 4.23e-07)
self.assertAlmostEqual(motif.instances[5].pvalue, 9.43e-07)
self.assertAlmostEqual(motif.instances[6].pvalue, 3.32e-06)
self.assertEqual(motif.instances[0].sequence_name, 'INO1')
self.assertEqual(motif.instances[1].sequence_name, 'FAS1')
self.assertEqual(motif.instances[2].sequence_name, 'ACC1')
self.assertEqual(motif.instances[3].sequence_name, 'CHO2')
self.assertEqual(motif.instances[4].sequence_name, 'CHO1')
self.assertEqual(motif.instances[5].sequence_name, 'FAS2')
self.assertEqual(motif.instances[6].sequence_name, 'OPI3')
self.assertEqual(motif.instances[0].strand, '-')
self.assertEqual(motif.instances[1].strand, '+')
self.assertEqual(motif.instances[2].strand, '+')
self.assertEqual(motif.instances[3].strand, '+')
self.assertEqual(motif.instances[4].strand, '+')
self.assertEqual(motif.instances[5].strand, '+')
self.assertEqual(motif.instances[6].strand, '+')
self.assertEqual(motif.instances[0].length, 12)
self.assertEqual(motif.instances[1].length, 12)
self.assertEqual(motif.instances[2].length, 12)
self.assertEqual(motif.instances[3].length, 12)
self.assertEqual(motif.instances[4].length, 12)
self.assertEqual(motif.instances[5].length, 12)
self.assertEqual(motif.instances[6].length, 12)
self.assertEqual(motif.instances[0].start, 620)
self.assertEqual(motif.instances[1].start, 95)
self.assertEqual(motif.instances[2].start, 83)
self.assertEqual(motif.instances[3].start, 354)
self.assertEqual(motif.instances[4].start, 611)
self.assertEqual(motif.instances[5].start, 567)
self.assertEqual(motif.instances[6].start, 340)
self.assertEqual(str(motif.instances[0]), "TTCACATGCCGC")
self.assertEqual(str(motif.instances[1]), "TTCACATGCCGC")
self.assertEqual(str(motif.instances[2]), "TTCACATGGCCC")
self.assertEqual(str(motif.instances[3]), "TTCTCATGCCGC")
self.assertEqual(str(motif.instances[4]), "TTCACACGGCAC")
self.assertEqual(str(motif.instances[5]), "TTCACATGCTAC")
self.assertEqual(str(motif.instances[6]), "TTCAGATCGCTC")
motif = record.motifs[1]
self.assertEqual(motif.num_occurrences, 7)
self.assertAlmostEqual(motif.evalue, 110)
self.assertEqual(motif.alphabet, IUPAC.unambiguous_dna)
self.assertEqual(motif.name, "Motif 2")
self.assertEqual(len(motif.instances), 7)
self.assertAlmostEqual(motif.instances[0].pvalue, 3.24e-07)
self.assertAlmostEqual(motif.instances[1].pvalue, 3.24e-07)
self.assertAlmostEqual(motif.instances[2].pvalue, 3.24e-07)
self.assertAlmostEqual(motif.instances[3].pvalue, 5.29e-06)
self.assertAlmostEqual(motif.instances[4].pvalue, 6.25e-06)
self.assertAlmostEqual(motif.instances[5].pvalue, 8.48e-06)
self.assertAlmostEqual(motif.instances[6].pvalue, 8.48e-06)
self.assertEqual(motif.instances[0].sequence_name, 'OPI3')
self.assertEqual(motif.instances[1].sequence_name, 'ACC1')
self.assertEqual(motif.instances[2].sequence_name, 'CHO1')
self.assertEqual(motif.instances[3].sequence_name, 'INO1')
self.assertEqual(motif.instances[4].sequence_name, 'FAS1')
self.assertEqual(motif.instances[5].sequence_name, 'FAS2')
self.assertEqual(motif.instances[6].sequence_name, 'CHO2')
self.assertEqual(motif.instances[0].strand, '-')
self.assertEqual(motif.instances[1].strand, '+')
self.assertEqual(motif.instances[2].strand, '-')
self.assertEqual(motif.instances[3].strand, '-')
self.assertEqual(motif.instances[4].strand, '+')
self.assertEqual(motif.instances[5].strand, '-')
self.assertEqual(motif.instances[6].strand, '-')
self.assertEqual(motif.instances[0].length, 10)
self.assertEqual(motif.instances[1].length, 10)
self.assertEqual(motif.instances[2].length, 10)
self.assertEqual(motif.instances[3].length, 10)
self.assertEqual(motif.instances[4].length, 10)
self.assertEqual(motif.instances[5].length, 10)
self.assertEqual(motif.instances[6].length, 10)
self.assertEqual(motif.instances[0].start, 186)
self.assertEqual(motif.instances[1].start, 232)
self.assertEqual(motif.instances[2].start, 559)
self.assertEqual(motif.instances[3].start, 283)
self.assertEqual(motif.instances[4].start, 44)
self.assertEqual(motif.instances[5].start, 185)
self.assertEqual(motif.instances[6].start, 413)
self.assertEqual(str(motif.instances[0]), "TCTGGCACAG")
self.assertEqual(str(motif.instances[1]), "TCTGGCACAG")
self.assertEqual(str(motif.instances[2]), "TCTGGCACAG")
self.assertEqual(str(motif.instances[3]), "GCGGGCGCAG")
self.assertEqual(str(motif.instances[4]), "GCAGGCACGG")
self.assertEqual(str(motif.instances[5]), "TCTGGCACTC")
self.assertEqual(str(motif.instances[6]), "TCTGGCATCG")
handle.close()
def test_meme_parser_3(self):
"""Test if Motif can parse MEME output files (third test)
"""
from Bio.Alphabet import IUPAC
from Bio.Motif import MEME
handle = open("Motif/meme.protein.oops.txt")
record = MEME.read(handle)
self.assertEqual(record.version, '3.0')
self.assertEqual(record.datafile, 'adh.s')
self.assertEqual(record.alphabet, IUPAC.protein)
self.assertEqual(len(record.sequences), 33)
self.assertEqual(record.sequences[0], "2BHD_STREX")
self.assertEqual(record.sequences[1], "3BHD_COMTE")
self.assertEqual(record.sequences[2], "ADH_DROME")
self.assertEqual(record.sequences[3], "AP27_MOUSE")
self.assertEqual(record.sequences[4], "BA72_EUBSP")
self.assertEqual(record.sequences[5], "BDH_HUMAN")
self.assertEqual(record.sequences[6], "BPHB_PSEPS")
self.assertEqual(record.sequences[7], "BUDC_KLETE")
self.assertEqual(record.sequences[8], "DHES_HUMAN")
self.assertEqual(record.sequences[9], "DHGB_BACME")
self.assertEqual(record.sequences[10], "DHII_HUMAN")
self.assertEqual(record.sequences[11], "DHMA_FLAS1")
self.assertEqual(record.sequences[12], "ENTA_ECOLI")
self.assertEqual(record.sequences[13], "FIXR_BRAJA")
self.assertEqual(record.sequences[14], "GUTD_ECOLI")
self.assertEqual(record.sequences[15], "HDE_CANTR")
self.assertEqual(record.sequences[16], "HDHA_ECOLI")
self.assertEqual(record.sequences[17], "LIGD_PSEPA")
self.assertEqual(record.sequences[18], "NODG_RHIME")
self.assertEqual(record.sequences[19], "RIDH_KLEAE")
self.assertEqual(record.sequences[20], "YINL_LISMO")
self.assertEqual(record.sequences[21], "YRTP_BACSU")
self.assertEqual(record.sequences[22], "CSGA_MYXXA")
self.assertEqual(record.sequences[23], "DHB2_HUMAN")
self.assertEqual(record.sequences[24], "DHB3_HUMAN")
self.assertEqual(record.sequences[25], "DHCA_HUMAN")
self.assertEqual(record.sequences[26], "FABI_ECOLI")
self.assertEqual(record.sequences[27], "FVT1_HUMAN")
self.assertEqual(record.sequences[28], "HMTR_LEIMA")
self.assertEqual(record.sequences[29], "MAS1_AGRRA")
self.assertEqual(record.sequences[30], "PCR_PEA")
self.assertEqual(record.sequences[31], "RFBB_NEIGO")
self.assertEqual(record.sequences[32], "YURA_MYXXA")
self.assertEqual(record.command, 'meme adh.s -mod oops -protein -nmotifs 2')
self.assertEqual(len(record.motifs), 2)
motif = record.motifs[0]
self.assertEqual(motif.num_occurrences, 33)
self.assertAlmostEqual(motif.evalue, 3.6e-165)
self.assertEqual(motif.alphabet, IUPAC.protein)
self.assertEqual(motif.name, "Motif 1")
self.assertEqual(len(motif.instances), 33)
self.assertAlmostEqual(motif.instances[0].pvalue, 1.64e-22)
self.assertAlmostEqual(motif.instances[1].pvalue, 6.32e-22)
self.assertAlmostEqual(motif.instances[2].pvalue, 1.13e-21)
self.assertAlmostEqual(motif.instances[3].pvalue, 4.04e-21)
self.assertAlmostEqual(motif.instances[4].pvalue, 6.12e-21)
self.assertAlmostEqual(motif.instances[5].pvalue, 7.52e-20)
self.assertAlmostEqual(motif.instances[6].pvalue, 3.35e-19)
self.assertAlmostEqual(motif.instances[7].pvalue, 4.82e-19)
self.assertAlmostEqual(motif.instances[8].pvalue, 4.82e-19)
self.assertAlmostEqual(motif.instances[9].pvalue, 1.11e-18)
self.assertAlmostEqual(motif.instances[10].pvalue, 1.25e-18)
self.assertAlmostEqual(motif.instances[11].pvalue, 2.23e-18)
self.assertAlmostEqual(motif.instances[12].pvalue, 5.53e-18)
self.assertAlmostEqual(motif.instances[13].pvalue, 9.65e-18)
self.assertAlmostEqual(motif.instances[14].pvalue, 2.86e-17)
self.assertAlmostEqual(motif.instances[15].pvalue, 8.20e-17)
self.assertAlmostEqual(motif.instances[16].pvalue, 9.09e-17)
self.assertAlmostEqual(motif.instances[17].pvalue, 1.37e-16)
self.assertAlmostEqual(motif.instances[18].pvalue, 2.52e-16)
self.assertAlmostEqual(motif.instances[19].pvalue, 1.21e-15)
self.assertAlmostEqual(motif.instances[20].pvalue, 1.61e-15)
self.assertAlmostEqual(motif.instances[21].pvalue, 1.77e-15)
self.assertAlmostEqual(motif.instances[22].pvalue, 7.81e-15)
self.assertAlmostEqual(motif.instances[23].pvalue, 8.55e-15)
self.assertAlmostEqual(motif.instances[24].pvalue, 1.47e-14)
self.assertAlmostEqual(motif.instances[25].pvalue, 3.24e-14)
self.assertAlmostEqual(motif.instances[26].pvalue, 1.80e-12)
self.assertAlmostEqual(motif.instances[27].pvalue, 2.10e-12)
self.assertAlmostEqual(motif.instances[28].pvalue, 4.15e-12)
self.assertAlmostEqual(motif.instances[29].pvalue, 5.20e-12)
self.assertAlmostEqual(motif.instances[30].pvalue, 4.80e-10)
self.assertAlmostEqual(motif.instances[31].pvalue, 2.77e-08)
self.assertAlmostEqual(motif.instances[32].pvalue, 5.72e-08)
self.assertEqual(motif.instances[0].sequence_name, 'YRTP_BACSU')
self.assertEqual(motif.instances[1].sequence_name, 'AP27_MOUSE')
self.assertEqual(motif.instances[2].sequence_name, 'NODG_RHIME')
self.assertEqual(motif.instances[3].sequence_name, 'BUDC_KLETE')
self.assertEqual(motif.instances[4].sequence_name, 'FIXR_BRAJA')
self.assertEqual(motif.instances[5].sequence_name, 'DHGB_BACME')
self.assertEqual(motif.instances[6].sequence_name, 'HMTR_LEIMA')
self.assertEqual(motif.instances[7].sequence_name, 'YURA_MYXXA')
self.assertEqual(motif.instances[8].sequence_name, 'GUTD_ECOLI')
self.assertEqual(motif.instances[9].sequence_name, '2BHD_STREX')
self.assertEqual(motif.instances[10].sequence_name, 'HDHA_ECOLI')
self.assertEqual(motif.instances[11].sequence_name, 'DHB2_HUMAN')
self.assertEqual(motif.instances[12].sequence_name, 'DHMA_FLAS1')
self.assertEqual(motif.instances[13].sequence_name, 'HDE_CANTR')
self.assertEqual(motif.instances[14].sequence_name, 'FVT1_HUMAN')
self.assertEqual(motif.instances[15].sequence_name, 'BDH_HUMAN')
self.assertEqual(motif.instances[16].sequence_name, 'RIDH_KLEAE')
self.assertEqual(motif.instances[17].sequence_name, 'DHES_HUMAN')
self.assertEqual(motif.instances[18].sequence_name, 'BA72_EUBSP')
self.assertEqual(motif.instances[19].sequence_name, 'LIGD_PSEPA')
self.assertEqual(motif.instances[20].sequence_name, 'DHII_HUMAN')
self.assertEqual(motif.instances[21].sequence_name, 'ENTA_ECOLI')
self.assertEqual(motif.instances[22].sequence_name, '3BHD_COMTE')
self.assertEqual(motif.instances[23].sequence_name, 'DHB3_HUMAN')
self.assertEqual(motif.instances[24].sequence_name, 'RFBB_NEIGO')
self.assertEqual(motif.instances[25].sequence_name, 'YINL_LISMO')
self.assertEqual(motif.instances[26].sequence_name, 'BPHB_PSEPS')
self.assertEqual(motif.instances[27].sequence_name, 'CSGA_MYXXA')
self.assertEqual(motif.instances[28].sequence_name, 'FABI_ECOLI')
self.assertEqual(motif.instances[29].sequence_name, 'ADH_DROME')
self.assertEqual(motif.instances[30].sequence_name, 'DHCA_HUMAN')
self.assertEqual(motif.instances[31].sequence_name, 'PCR_PEA')
self.assertEqual(motif.instances[32].sequence_name, 'MAS1_AGRRA')
self.assertEqual(motif.instances[0].strand, '+')
self.assertEqual(motif.instances[1].strand, '+')
self.assertEqual(motif.instances[2].strand, '+')
self.assertEqual(motif.instances[3].strand, '+')
self.assertEqual(motif.instances[4].strand, '+')
self.assertEqual(motif.instances[5].strand, '+')
self.assertEqual(motif.instances[6].strand, '+')
self.assertEqual(motif.instances[7].strand, '+')
self.assertEqual(motif.instances[8].strand, '+')
self.assertEqual(motif.instances[9].strand, '+')
self.assertEqual(motif.instances[10].strand, '+')
self.assertEqual(motif.instances[11].strand, '+')
self.assertEqual(motif.instances[12].strand, '+')
self.assertEqual(motif.instances[13].strand, '+')
self.assertEqual(motif.instances[14].strand, '+')
self.assertEqual(motif.instances[15].strand, '+')
self.assertEqual(motif.instances[16].strand, '+')
self.assertEqual(motif.instances[17].strand, '+')
self.assertEqual(motif.instances[18].strand, '+')
self.assertEqual(motif.instances[19].strand, '+')
self.assertEqual(motif.instances[20].strand, '+')
self.assertEqual(motif.instances[21].strand, '+')
self.assertEqual(motif.instances[22].strand, '+')
self.assertEqual(motif.instances[23].strand, '+')
self.assertEqual(motif.instances[24].strand, '+')
self.assertEqual(motif.instances[25].strand, '+')
self.assertEqual(motif.instances[26].strand, '+')
self.assertEqual(motif.instances[27].strand, '+')
self.assertEqual(motif.instances[28].strand, '+')
self.assertEqual(motif.instances[29].strand, '+')
self.assertEqual(motif.instances[30].strand, '+')
self.assertEqual(motif.instances[31].strand, '+')
self.assertEqual(motif.instances[32].strand, '+')
self.assertEqual(motif.instances[0].length, 29)
self.assertEqual(motif.instances[1].length, 29)
self.assertEqual(motif.instances[2].length, 29)
self.assertEqual(motif.instances[3].length, 29)
self.assertEqual(motif.instances[4].length, 29)
self.assertEqual(motif.instances[5].length, 29)
self.assertEqual(motif.instances[6].length, 29)
self.assertEqual(motif.instances[7].length, 29)
self.assertEqual(motif.instances[8].length, 29)
self.assertEqual(motif.instances[9].length, 29)
self.assertEqual(motif.instances[10].length, 29)
self.assertEqual(motif.instances[11].length, 29)
self.assertEqual(motif.instances[12].length, 29)
self.assertEqual(motif.instances[13].length, 29)
self.assertEqual(motif.instances[14].length, 29)
self.assertEqual(motif.instances[15].length, 29)
self.assertEqual(motif.instances[16].length, 29)
self.assertEqual(motif.instances[17].length, 29)
self.assertEqual(motif.instances[18].length, 29)
self.assertEqual(motif.instances[19].length, 29)
self.assertEqual(motif.instances[20].length, 29)
self.assertEqual(motif.instances[21].length, 29)
self.assertEqual(motif.instances[22].length, 29)
self.assertEqual(motif.instances[23].length, 29)
self.assertEqual(motif.instances[24].length, 29)
self.assertEqual(motif.instances[25].length, 29)
self.assertEqual(motif.instances[26].length, 29)
self.assertEqual(motif.instances[27].length, 29)
self.assertEqual(motif.instances[28].length, 29)
self.assertEqual(motif.instances[29].length, 29)
self.assertEqual(motif.instances[30].length, 29)
self.assertEqual(motif.instances[31].length, 29)
self.assertEqual(motif.instances[32].length, 29)
self.assertEqual(motif.instances[0].start, 155)
self.assertEqual(motif.instances[1].start, 149)
self.assertEqual(motif.instances[2].start, 152)
self.assertEqual(motif.instances[3].start, 152)
self.assertEqual(motif.instances[4].start, 189)
self.assertEqual(motif.instances[5].start, 160)
self.assertEqual(motif.instances[6].start, 193)
self.assertEqual(motif.instances[7].start, 160)
self.assertEqual(motif.instances[8].start, 154)
self.assertEqual(motif.instances[9].start, 152)
self.assertEqual(motif.instances[10].start, 159)
self.assertEqual(motif.instances[11].start, 232)
self.assertEqual(motif.instances[12].start, 165)
self.assertEqual(motif.instances[13].start, 467)
self.assertEqual(motif.instances[14].start, 186)
self.assertEqual(motif.instances[15].start, 208)
self.assertEqual(motif.instances[16].start, 160)
self.assertEqual(motif.instances[17].start, 155)
self.assertEqual(motif.instances[18].start, 157)
self.assertEqual(motif.instances[19].start, 157)
self.assertEqual(motif.instances[20].start, 183)
self.assertEqual(motif.instances[21].start, 144)
self.assertEqual(motif.instances[22].start, 151)
self.assertEqual(motif.instances[23].start, 198)
self.assertEqual(motif.instances[24].start, 165)
self.assertEqual(motif.instances[25].start, 154)
self.assertEqual(motif.instances[26].start, 153)
self.assertEqual(motif.instances[27].start, 88)
self.assertEqual(motif.instances[28].start, 159)
self.assertEqual(motif.instances[29].start, 152)
self.assertEqual(motif.instances[30].start, 193)
self.assertEqual(motif.instances[31].start, 26)
self.assertEqual(motif.instances[32].start, 349)
self.assertEqual(str(motif.instances[0]), "YSASKFAVLGLTESLMQEVRKHNIRVSAL")
self.assertEqual(str(motif.instances[1]), "YSSTKGAMTMLTKAMAMELGPHKIRVNSV")
self.assertEqual(str(motif.instances[2]), "YCASKAGMIGFSKSLAQEIATRNITVNCV")
self.assertEqual(str(motif.instances[3]), "YSSSKFAVRGLTQTAARDLAPLGITVNGF")
self.assertEqual(str(motif.instances[4]), "YATSKAALASLTRELAHDYAPHGIRVNAI")
self.assertEqual(str(motif.instances[5]), "YAASKGGMKLMTETLALEYAPKGIRVNNI")
self.assertEqual(str(motif.instances[6]), "YTMAKGALEGLTRSAALELAPLQIRVNGV")
self.assertEqual(str(motif.instances[7]), "YSASKAFLSTFMESLRVDLRGTGVRVTCI")
self.assertEqual(str(motif.instances[8]), "YSAAKFGGVGLTQSLALDLAEYGITVHSL")
self.assertEqual(str(motif.instances[9]), "YGASKWGVRGLSKLAAVELGTDRIRVNSV")
self.assertEqual(str(motif.instances[10]), "YASSKAAASHLVRNMAFDLGEKNIRVNGI")
self.assertEqual(str(motif.instances[11]), "YGSSKAAVTMFSSVMRLELSKWGIKVASI")
self.assertEqual(str(motif.instances[12]), "YVAAKGGVAMLTRAMAVDLARHGILVNMI")
self.assertEqual(str(motif.instances[13]), "YSSSKAGILGLSKTMAIEGAKNNIKVNIV")
self.assertEqual(str(motif.instances[14]), "YSASKFAIRGLAEALQMEVKPYNVYITVA")
self.assertEqual(str(motif.instances[15]), "YCITKFGVEAFSDCLRYEMYPLGVKVSVV")
self.assertEqual(str(motif.instances[16]), "YTASKFAVQAFVHTTRRQVAQYGVRVGAV")
self.assertEqual(str(motif.instances[17]), "YCASKFALEGLCESLAVLLLPFGVHLSLI")
self.assertEqual(str(motif.instances[18]), "YPASKASVIGLTHGLGREIIRKNIRVVGV")
self.assertEqual(str(motif.instances[19]), "YSAAKAASINLMEGYRQGLEKYGIGVSVC")
self.assertEqual(str(motif.instances[20]), "YSASKFALDGFFSSIRKEYSVSRVNVSIT")
self.assertEqual(str(motif.instances[21]), "YGASKAALKSLALSVGLELAGSGVRCNVV")
self.assertEqual(str(motif.instances[22]), "YSASKAAVSALTRAAALSCRKQGYAIRVN")
self.assertEqual(str(motif.instances[23]), "YSASKAFVCAFSKALQEEYKAKEVIIQVL")
self.assertEqual(str(motif.instances[24]), "YSASKAAADHLVRAWQRTYRLPSIVSNCS")
self.assertEqual(str(motif.instances[25]), "YGATKWAVRDLMEVLRMESAQEGTNIRTA")
self.assertEqual(str(motif.instances[26]), "YTAAKQAIVGLVRELAFELAPYVRVNGVG")
self.assertEqual(str(motif.instances[27]), "YRMSKAALNMAVRSMSTDLRPEGFVTVLL")
self.assertEqual(str(motif.instances[28]), "MGLAKASLEANVRYMANAMGPEGVRVNAI")
self.assertEqual(str(motif.instances[29]), "YSGTKAAVVNFTSSLAKLAPITGVTAYTV")
self.assertEqual(str(motif.instances[30]), "YGVTKIGVTVLSRIHARKLSEQRKGDKIL")
self.assertEqual(str(motif.instances[31]), "KDSTLFGVSSLSDSLKGDFTSSALRCKEL")
self.assertEqual(str(motif.instances[32]), "YINCVAPLRMTELCLPHLYETGSGRIVNI")
motif = record.motifs[1]
self.assertEqual(motif.num_occurrences, 33)
self.assertAlmostEqual(motif.evalue, 2.3e-159)
self.assertEqual(motif.alphabet, IUPAC.protein)
self.assertEqual(motif.name, "Motif 2")
self.assertEqual(len(motif.instances), 33)
self.assertAlmostEqual(motif.instances[0].pvalue, 2.44e-23)
self.assertAlmostEqual(motif.instances[1].pvalue, 5.50e-23)
self.assertAlmostEqual(motif.instances[2].pvalue, 5.38e-22)
self.assertAlmostEqual(motif.instances[3].pvalue, 5.65e-20)
self.assertAlmostEqual(motif.instances[4].pvalue, 1.17e-19)
self.assertAlmostEqual(motif.instances[5].pvalue, 1.17e-19)
self.assertAlmostEqual(motif.instances[6].pvalue, 4.74e-19)
self.assertAlmostEqual(motif.instances[7].pvalue, 9.31e-19)
self.assertAlmostEqual(motif.instances[8].pvalue, 2.50e-18)
self.assertAlmostEqual(motif.instances[9].pvalue, 3.45e-18)
self.assertAlmostEqual(motif.instances[10].pvalue, 5.86e-18)
self.assertAlmostEqual(motif.instances[11].pvalue, 9.86e-18)
self.assertAlmostEqual(motif.instances[12].pvalue, 2.47e-17)
self.assertAlmostEqual(motif.instances[13].pvalue, 3.01e-17)
self.assertAlmostEqual(motif.instances[14].pvalue, 3.33e-17)
self.assertAlmostEqual(motif.instances[15].pvalue, 4.06e-17)
self.assertAlmostEqual(motif.instances[16].pvalue, 4.06e-17)
self.assertAlmostEqual(motif.instances[17].pvalue, 8.05e-17)
self.assertAlmostEqual(motif.instances[18].pvalue, 1.90e-16)
self.assertAlmostEqual(motif.instances[19].pvalue, 2.77e-16)
self.assertAlmostEqual(motif.instances[20].pvalue, 3.65e-16)
self.assertAlmostEqual(motif.instances[21].pvalue, 8.31e-16)
self.assertAlmostEqual(motif.instances[22].pvalue, 4.05e-15)
self.assertAlmostEqual(motif.instances[23].pvalue, 5.24e-15)
self.assertAlmostEqual(motif.instances[24].pvalue, 3.00e-14)
self.assertAlmostEqual(motif.instances[25].pvalue, 8.47e-14)
self.assertAlmostEqual(motif.instances[26].pvalue, 1.46e-13)
self.assertAlmostEqual(motif.instances[27].pvalue, 1.46e-13)
self.assertAlmostEqual(motif.instances[28].pvalue, 1.59e-12)
self.assertAlmostEqual(motif.instances[29].pvalue, 6.97e-10)
self.assertAlmostEqual(motif.instances[30].pvalue, 3.15e-09)
self.assertAlmostEqual(motif.instances[31].pvalue, 2.77e-07)
self.assertAlmostEqual(motif.instances[32].pvalue, 4.24e-07)
self.assertEqual(motif.instances[0].sequence_name, 'HDE_CANTR')
self.assertEqual(motif.instances[1].sequence_name, 'DHII_HUMAN')
self.assertEqual(motif.instances[2].sequence_name, 'YINL_LISMO')
self.assertEqual(motif.instances[3].sequence_name, 'HDHA_ECOLI')
self.assertEqual(motif.instances[4].sequence_name, 'RIDH_KLEAE')
self.assertEqual(motif.instances[5].sequence_name, 'BUDC_KLETE')
self.assertEqual(motif.instances[6].sequence_name, 'ENTA_ECOLI')
self.assertEqual(motif.instances[7].sequence_name, 'AP27_MOUSE')
self.assertEqual(motif.instances[8].sequence_name, 'DHMA_FLAS1')
self.assertEqual(motif.instances[9].sequence_name, 'YRTP_BACSU')
self.assertEqual(motif.instances[10].sequence_name, 'DHGB_BACME')
self.assertEqual(motif.instances[11].sequence_name, 'DHB3_HUMAN')
self.assertEqual(motif.instances[12].sequence_name, 'PCR_PEA')
self.assertEqual(motif.instances[13].sequence_name, 'BDH_HUMAN')
self.assertEqual(motif.instances[14].sequence_name, 'BA72_EUBSP')
self.assertEqual(motif.instances[15].sequence_name, 'FIXR_BRAJA')
self.assertEqual(motif.instances[16].sequence_name, '3BHD_COMTE')
self.assertEqual(motif.instances[17].sequence_name, '2BHD_STREX')
self.assertEqual(motif.instances[18].sequence_name, 'HMTR_LEIMA')
self.assertEqual(motif.instances[19].sequence_name, 'FVT1_HUMAN')
self.assertEqual(motif.instances[20].sequence_name, 'DHB2_HUMAN')
self.assertEqual(motif.instances[21].sequence_name, 'LIGD_PSEPA')
self.assertEqual(motif.instances[22].sequence_name, 'NODG_RHIME')
self.assertEqual(motif.instances[23].sequence_name, 'DHCA_HUMAN')
self.assertEqual(motif.instances[24].sequence_name, 'MAS1_AGRRA')
self.assertEqual(motif.instances[25].sequence_name, 'BPHB_PSEPS')
self.assertEqual(motif.instances[26].sequence_name, 'GUTD_ECOLI')
self.assertEqual(motif.instances[27].sequence_name, 'DHES_HUMAN')
self.assertEqual(motif.instances[28].sequence_name, 'RFBB_NEIGO')
self.assertEqual(motif.instances[29].sequence_name, 'ADH_DROME')
self.assertEqual(motif.instances[30].sequence_name, 'FABI_ECOLI')
self.assertEqual(motif.instances[31].sequence_name, 'YURA_MYXXA')
self.assertEqual(motif.instances[32].sequence_name, 'CSGA_MYXXA')
self.assertEqual(motif.instances[0].start, 323)
self.assertEqual(motif.instances[1].start, 35)
self.assertEqual(motif.instances[2].start, 6)
self.assertEqual(motif.instances[3].start, 12)
self.assertEqual(motif.instances[4].start, 15)
self.assertEqual(motif.instances[5].start, 3)
self.assertEqual(motif.instances[6].start, 6)
self.assertEqual(motif.instances[7].start, 8)
self.assertEqual(motif.instances[8].start, 15)
self.assertEqual(motif.instances[9].start, 7)
self.assertEqual(motif.instances[10].start, 8)
self.assertEqual(motif.instances[11].start, 49)
self.assertEqual(motif.instances[12].start, 87)
self.assertEqual(motif.instances[13].start, 56)
self.assertEqual(motif.instances[14].start, 7)
self.assertEqual(motif.instances[15].start, 37)
self.assertEqual(motif.instances[16].start, 7)
self.assertEqual(motif.instances[17].start, 7)
self.assertEqual(motif.instances[18].start, 7)
self.assertEqual(motif.instances[19].start, 33)
self.assertEqual(motif.instances[20].start, 83)
self.assertEqual(motif.instances[21].start, 7)
self.assertEqual(motif.instances[22].start, 7)
self.assertEqual(motif.instances[23].start, 5)
self.assertEqual(motif.instances[24].start, 246)
self.assertEqual(motif.instances[25].start, 6)
self.assertEqual(motif.instances[26].start, 3)
self.assertEqual(motif.instances[27].start, 3)
self.assertEqual(motif.instances[28].start, 7)
self.assertEqual(motif.instances[29].start, 7)
self.assertEqual(motif.instances[30].start, 7)
self.assertEqual(motif.instances[31].start, 117)
self.assertEqual(motif.instances[32].start, 52)
self.assertEqual(str(motif.instances[0]), 'KVVLITGAGAGLGKEYAKWFAKYGAKVVV')
self.assertEqual(str(motif.instances[1]), 'KKVIVTGASKGIGREMAYHLAKMGAHVVV')
self.assertEqual(str(motif.instances[2]), 'KVIIITGASSGIGKATALLLAEKGAKLVL')
self.assertEqual(str(motif.instances[3]), 'KCAIITGAGAGIGKEIAITFATAGASVVV')
self.assertEqual(str(motif.instances[4]), 'KVAAITGAASGIGLECARTLLGAGAKVVL')
self.assertEqual(str(motif.instances[5]), 'KVALVTGAGQGIGKAIALRLVKDGFAVAI')
self.assertEqual(str(motif.instances[6]), 'KNVWVTGAGKGIGYATALAFVEAGAKVTG')
self.assertEqual(str(motif.instances[7]), 'LRALVTGAGKGIGRDTVKALHASGAKVVA')
self.assertEqual(str(motif.instances[8]), 'KAAIVTGAAGGIGRATVEAYLREGASVVA')
self.assertEqual(str(motif.instances[9]), 'KTALITGGGRGIGRATALALAKEGVNIGL')
self.assertEqual(str(motif.instances[10]), 'KVVVITGSSTGLGKSMAIRFATEKAKVVV')
self.assertEqual(str(motif.instances[11]), 'QWAVITGAGDGIGKAYSFELAKRGLNVVL')
self.assertEqual(str(motif.instances[12]), 'GNVVITGASSGLGLATAKALAESGKWHVI')
self.assertEqual(str(motif.instances[13]), 'KAVLVTGCDSGFGFSLAKHLHSKGFLVFA')
self.assertEqual(str(motif.instances[14]), 'KVTIITGGTRGIGFAAAKIFIDNGAKVSI')
self.assertEqual(str(motif.instances[15]), 'KVMLLTGASRGIGHATAKLFSEAGWRIIS')
self.assertEqual(str(motif.instances[16]), 'KVALVTGGASGVGLEVVKLLLGEGAKVAF')
self.assertEqual(str(motif.instances[17]), 'KTVIITGGARGLGAEAARQAVAAGARVVL')
self.assertEqual(str(motif.instances[18]), 'PVALVTGAAKRLGRSIAEGLHAEGYAVCL')
self.assertEqual(str(motif.instances[19]), 'AHVVVTGGSSGIGKCIAIECYKQGAFITL')
self.assertEqual(str(motif.instances[20]), 'KAVLVTGGDCGLGHALCKYLDELGFTVFA')
self.assertEqual(str(motif.instances[21]), 'QVAFITGGASGAGFGQAKVFGQAGAKIVV')
self.assertEqual(str(motif.instances[22]), 'RKALVTGASGAIGGAIARVLHAQGAIVGL')
self.assertEqual(str(motif.instances[23]), 'HVALVTGGNKGIGLAIVRDLCRLFSGDVV')
self.assertEqual(str(motif.instances[24]), 'PVILVSGSNRGVGKAIAEDLIAHGYRLSL')
self.assertEqual(str(motif.instances[25]), 'EAVLITGGASGLGRALVDRFVAEAKVAVL')
self.assertEqual(str(motif.instances[26]), 'QVAVVIGGGQTLGAFLCHGLAAEGYRVAV')
self.assertEqual(str(motif.instances[27]), 'TVVLITGCSSGIGLHLAVRLASDPSQSFK')
self.assertEqual(str(motif.instances[28]), 'KNILVTGGAGFIGSAVVRHIIQNTRDSVV')
self.assertEqual(str(motif.instances[29]), 'KNVIFVAGLGGIGLDTSKELLKRDLKNLV')
self.assertEqual(str(motif.instances[30]), 'KRILVTGVASKLSIAYGIAQAMHREGAEL')
self.assertEqual(str(motif.instances[31]), 'IDTNVTGAAATLSAVLPQMVERKRGHLVG')
self.assertEqual(str(motif.instances[32]), 'TSAMLPGLRQGALRRVAHVTSRMGSLAAN')
handle.close()
def test_meme_parser_4(self):
"""Test if Motif can parse MEME output files (fourth test)
"""
from Bio.Alphabet import IUPAC
from Bio.Motif import MEME
handle = open("Motif/meme.protein.tcm.txt")
record = MEME.read(handle)
self.assertEqual(record.version, '3.0')
self.assertEqual(record.datafile, 'farntrans5.s')
self.assertEqual(record.alphabet, IUPAC.protein)
self.assertEqual(len(record.sequences), 5)
self.assertEqual(record.sequences[0], "RAM1_YEAST")
self.assertEqual(record.sequences[1], "PFTB_RAT")
self.assertEqual(record.sequences[2], "BET2_YEAST")
self.assertEqual(record.sequences[3], "RATRABGERB")
self.assertEqual(record.sequences[4], "CAL1_YEAST")
self.assertEqual(record.command, 'meme farntrans5.s -mod tcm -protein -nmotifs 2')
self.assertEqual(len(record.motifs), 2)
motif = record.motifs[0]
self.assertEqual(motif.num_occurrences, 24)
self.assertAlmostEqual(motif.evalue, 2.2e-94)
self.assertEqual(motif.alphabet, IUPAC.protein)
self.assertEqual(motif.name, "Motif 1")
self.assertEqual(len(motif.instances), 24)
self.assertAlmostEqual(motif.instances[0].pvalue, 7.28e-22)
self.assertAlmostEqual(motif.instances[1].pvalue, 6.18e-21)
self.assertAlmostEqual(motif.instances[2].pvalue, 9.17e-20)
self.assertAlmostEqual(motif.instances[3].pvalue, 1.15e-19)
self.assertAlmostEqual(motif.instances[4].pvalue, 4.30e-19)
self.assertAlmostEqual(motif.instances[5].pvalue, 7.36e-19)
self.assertAlmostEqual(motif.instances[6].pvalue, 8.19e-19)
self.assertAlmostEqual(motif.instances[7].pvalue, 2.10e-18)
self.assertAlmostEqual(motif.instances[8].pvalue, 1.43e-17)
self.assertAlmostEqual(motif.instances[9].pvalue, 3.41e-17)
self.assertAlmostEqual(motif.instances[10].pvalue, 5.00e-17)
self.assertAlmostEqual(motif.instances[11].pvalue, 6.64e-17)
self.assertAlmostEqual(motif.instances[12].pvalue, 1.27e-16)
self.assertAlmostEqual(motif.instances[13].pvalue, 3.17e-16)
self.assertAlmostEqual(motif.instances[14].pvalue, 3.47e-16)
self.assertAlmostEqual(motif.instances[15].pvalue, 4.30e-15)
self.assertAlmostEqual(motif.instances[16].pvalue, 2.40e-14)
self.assertAlmostEqual(motif.instances[17].pvalue, 2.81e-14)
self.assertAlmostEqual(motif.instances[18].pvalue, 7.78e-14)
self.assertAlmostEqual(motif.instances[19].pvalue, 1.14e-13)
self.assertAlmostEqual(motif.instances[20].pvalue, 1.33e-13)
self.assertAlmostEqual(motif.instances[21].pvalue, 3.52e-13)
self.assertAlmostEqual(motif.instances[22].pvalue, 5.47e-13)
self.assertAlmostEqual(motif.instances[23].pvalue, 3.11e-10)
self.assertEqual(motif.instances[0].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[1].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[2].sequence_name, "CAL1_YEAST")
self.assertEqual(motif.instances[3].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[4].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[5].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[6].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[7].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[8].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[9].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[10].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[11].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[12].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[13].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[14].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[15].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[16].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[17].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[18].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[19].sequence_name, "CAL1_YEAST")
self.assertEqual(motif.instances[20].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[21].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[22].sequence_name, "CAL1_YEAST")
self.assertEqual(motif.instances[23].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[0].strand, '+')
self.assertEqual(motif.instances[1].strand, '+')
self.assertEqual(motif.instances[2].strand, '+')
self.assertEqual(motif.instances[3].strand, '+')
self.assertEqual(motif.instances[4].strand, '+')
self.assertEqual(motif.instances[5].strand, '+')
self.assertEqual(motif.instances[6].strand, '+')
self.assertEqual(motif.instances[7].strand, '+')
self.assertEqual(motif.instances[8].strand, '+')
self.assertEqual(motif.instances[9].strand, '+')
self.assertEqual(motif.instances[10].strand, '+')
self.assertEqual(motif.instances[11].strand, '+')
self.assertEqual(motif.instances[12].strand, '+')
self.assertEqual(motif.instances[13].strand, '+')
self.assertEqual(motif.instances[14].strand, '+')
self.assertEqual(motif.instances[15].strand, '+')
self.assertEqual(motif.instances[16].strand, '+')
self.assertEqual(motif.instances[17].strand, '+')
self.assertEqual(motif.instances[18].strand, '+')
self.assertEqual(motif.instances[19].strand, '+')
self.assertEqual(motif.instances[20].strand, '+')
self.assertEqual(motif.instances[21].strand, '+')
self.assertEqual(motif.instances[22].strand, '+')
self.assertEqual(motif.instances[23].strand, '+')
self.assertEqual(motif.instances[0].length, 30)
self.assertEqual(motif.instances[1].length, 30)
self.assertEqual(motif.instances[2].length, 30)
self.assertEqual(motif.instances[3].length, 30)
self.assertEqual(motif.instances[4].length, 30)
self.assertEqual(motif.instances[5].length, 30)
self.assertEqual(motif.instances[6].length, 30)
self.assertEqual(motif.instances[7].length, 30)
self.assertEqual(motif.instances[8].length, 30)
self.assertEqual(motif.instances[9].length, 30)
self.assertEqual(motif.instances[10].length, 30)
self.assertEqual(motif.instances[11].length, 30)
self.assertEqual(motif.instances[12].length, 30)
self.assertEqual(motif.instances[13].length, 30)
self.assertEqual(motif.instances[14].length, 30)
self.assertEqual(motif.instances[15].length, 30)
self.assertEqual(motif.instances[16].length, 30)
self.assertEqual(motif.instances[17].length, 30)
self.assertEqual(motif.instances[18].length, 30)
self.assertEqual(motif.instances[19].length, 30)
self.assertEqual(motif.instances[20].length, 30)
self.assertEqual(motif.instances[21].length, 30)
self.assertEqual(motif.instances[22].length, 30)
self.assertEqual(motif.instances[23].length, 30)
self.assertEqual(motif.instances[0].start, 223)
self.assertEqual(motif.instances[1].start, 227)
self.assertEqual(motif.instances[2].start, 275)
self.assertEqual(motif.instances[3].start, 237)
self.assertEqual(motif.instances[4].start, 138)
self.assertEqual(motif.instances[5].start, 179)
self.assertEqual(motif.instances[6].start, 131)
self.assertEqual(motif.instances[7].start, 172)
self.assertEqual(motif.instances[8].start, 276)
self.assertEqual(motif.instances[9].start, 124)
self.assertEqual(motif.instances[10].start, 247)
self.assertEqual(motif.instances[11].start, 272)
self.assertEqual(motif.instances[12].start, 145)
self.assertEqual(motif.instances[13].start, 286)
self.assertEqual(motif.instances[14].start, 296)
self.assertEqual(motif.instances[15].start, 348)
self.assertEqual(motif.instances[16].start, 83)
self.assertEqual(motif.instances[17].start, 189)
self.assertEqual(motif.instances[18].start, 73)
self.assertEqual(motif.instances[19].start, 205)
self.assertEqual(motif.instances[20].start, 198)
self.assertEqual(motif.instances[21].start, 349)
self.assertEqual(motif.instances[22].start, 327)
self.assertEqual(motif.instances[23].start, 24)
self.assertEqual(str(motif.instances[0]), "GGLNGRPSKLPDVCYSWWVLSSLAIIGRLD")
self.assertEqual(str(motif.instances[1]), "GGLNGRPEKLPDVCYSWWVLASLKIIGRLH")
self.assertEqual(str(motif.instances[2]), "GGFQGRENKFADTCYAFWCLNSLHLLTKDW")
self.assertEqual(str(motif.instances[3]), "GGIGGVPGMEAHGGYTFCGLAALVILKKER")
self.assertEqual(str(motif.instances[4]), "GGFGGGPGQYPHLAPTYAAVNALCIIGTEE")
self.assertEqual(str(motif.instances[5]), "GGFGCRPGSESHAGQIYCCTGFLAITSQLH")
self.assertEqual(str(motif.instances[6]), "GSFAGDIWGEIDTRFSFCAVATLALLGKLD")
self.assertEqual(str(motif.instances[7]), "GGFGLCPNAESHAAQAFTCLGALAIANKLD")
self.assertEqual(str(motif.instances[8]), "GGFADRPGDMVDPFHTLFGIAGLSLLGEEQ")
self.assertEqual(str(motif.instances[9]), "GSFQGDRFGEVDTRFVYTALSALSILGELT")
self.assertEqual(str(motif.instances[10]), "GFGSCPHVDEAHGGYTFCATASLAILRSMD")
self.assertEqual(str(motif.instances[11]), "GGISDRPENEVDVFHTVFGVAGLSLMGYDN")
self.assertEqual(str(motif.instances[12]), "GPFGGGPGQLSHLASTYAAINALSLCDNID")
self.assertEqual(str(motif.instances[13]), "GGFQGRCNKLVDGCYSFWQAGLLPLLHRAL")
self.assertEqual(str(motif.instances[14]), "RGFCGRSNKLVDGCYSFWVGGSAAILEAFG")
self.assertEqual(str(motif.instances[15]), "GGLLDKPGKSRDFYHTCYCLSGLSIAQHFG")
self.assertEqual(str(motif.instances[16]), "GGVSASIGHDPHLLYTLSAVQILTLYDSIH")
self.assertEqual(str(motif.instances[17]), "GSFLMHVGGEVDVRSAYCAASVASLTNIIT")
self.assertEqual(str(motif.instances[18]), "GAFAPFPRHDAHLLTTLSAVQILATYDALD")
self.assertEqual(str(motif.instances[19]), "YNGAFGAHNEPHSGYTSCALSTLALLSSLE")
self.assertEqual(str(motif.instances[20]), "GFKTCLEVGEVDTRGIYCALSIATLLNILT")
self.assertEqual(str(motif.instances[21]), "PGLRDKPGAHSDFYHTNYCLLGLAVAESSY")
self.assertEqual(str(motif.instances[22]), "GGFSKNDEEDADLYHSCLGSAALALIEGKF")
self.assertEqual(str(motif.instances[23]), "HNFEYWLTEHLRLNGIYWGLTALCVLDSPE")
motif = record.motifs[1]
self.assertEqual(motif.num_occurrences, 21)
self.assertAlmostEqual(motif.evalue, 3.1e-19)
self.assertEqual(motif.alphabet, IUPAC.protein)
self.assertEqual(motif.name, "Motif 2")
self.assertEqual(len(motif.instances), 21)
self.assertAlmostEqual(motif.instances[0].pvalue, 2.24e-13)
self.assertAlmostEqual(motif.instances[1].pvalue, 1.30e-12)
self.assertAlmostEqual(motif.instances[2].pvalue, 4.20e-12)
self.assertAlmostEqual(motif.instances[3].pvalue, 9.60e-12)
self.assertAlmostEqual(motif.instances[4].pvalue, 5.08e-11)
self.assertAlmostEqual(motif.instances[5].pvalue, 5.01e-10)
self.assertAlmostEqual(motif.instances[6].pvalue, 6.90e-10)
self.assertAlmostEqual(motif.instances[7].pvalue, 1.57e-09)
self.assertAlmostEqual(motif.instances[8].pvalue, 2.34e-09)
self.assertAlmostEqual(motif.instances[9].pvalue, 4.59e-09)
self.assertAlmostEqual(motif.instances[10].pvalue, 1.65e-08)
self.assertAlmostEqual(motif.instances[11].pvalue, 1.65e-08)
self.assertAlmostEqual(motif.instances[12].pvalue, 1.65e-08)
self.assertAlmostEqual(motif.instances[13].pvalue, 2.54e-08)
self.assertAlmostEqual(motif.instances[14].pvalue, 4.58e-08)
self.assertAlmostEqual(motif.instances[15].pvalue, 5.86e-08)
self.assertAlmostEqual(motif.instances[16].pvalue, 1.52e-07)
self.assertAlmostEqual(motif.instances[17].pvalue, 1.91e-07)
self.assertAlmostEqual(motif.instances[18].pvalue, 4.34e-07)
self.assertAlmostEqual(motif.instances[19].pvalue, 5.01e-07)
self.assertAlmostEqual(motif.instances[20].pvalue, 5.78e-07)
self.assertEqual(motif.instances[0].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[1].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[2].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[3].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[4].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[5].sequence_name, "CAL1_YEAST")
self.assertEqual(motif.instances[6].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[7].sequence_name, "RATRABGERB")
self.assertEqual(motif.instances[8].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[9].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[10].sequence_name, "CAL1_YEAST")
self.assertEqual(motif.instances[11].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[12].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[13].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[14].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[15].sequence_name, "CAL1_YEAST")
self.assertEqual(motif.instances[16].sequence_name, "PFTB_RAT")
self.assertEqual(motif.instances[17].sequence_name, "CAL1_YEAST")
self.assertEqual(motif.instances[18].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[19].sequence_name, "BET2_YEAST")
self.assertEqual(motif.instances[20].sequence_name, "RAM1_YEAST")
self.assertEqual(motif.instances[0].strand, '+')
self.assertEqual(motif.instances[1].strand, '+')
self.assertEqual(motif.instances[2].strand, '+')
self.assertEqual(motif.instances[3].strand, '+')
self.assertEqual(motif.instances[4].strand, '+')
self.assertEqual(motif.instances[5].strand, '+')
self.assertEqual(motif.instances[6].strand, '+')
self.assertEqual(motif.instances[7].strand, '+')
self.assertEqual(motif.instances[8].strand, '+')
self.assertEqual(motif.instances[9].strand, '+')
self.assertEqual(motif.instances[10].strand, '+')
self.assertEqual(motif.instances[11].strand, '+')
self.assertEqual(motif.instances[12].strand, '+')
self.assertEqual(motif.instances[13].strand, '+')
self.assertEqual(motif.instances[14].strand, '+')
self.assertEqual(motif.instances[15].strand, '+')
self.assertEqual(motif.instances[16].strand, '+')
self.assertEqual(motif.instances[17].strand, '+')
self.assertEqual(motif.instances[18].strand, '+')
self.assertEqual(motif.instances[19].strand, '+')
self.assertEqual(motif.instances[20].strand, '+')
self.assertEqual(motif.instances[0].length, 14)
self.assertEqual(motif.instances[1].length, 14)
self.assertEqual(motif.instances[2].length, 14)
self.assertEqual(motif.instances[3].length, 14)
self.assertEqual(motif.instances[4].length, 14)
self.assertEqual(motif.instances[5].length, 14)
self.assertEqual(motif.instances[6].length, 14)
self.assertEqual(motif.instances[7].length, 14)
self.assertEqual(motif.instances[8].length, 14)
self.assertEqual(motif.instances[9].length, 14)
self.assertEqual(motif.instances[10].length, 14)
self.assertEqual(motif.instances[11].length, 14)
self.assertEqual(motif.instances[12].length, 14)
self.assertEqual(motif.instances[13].length, 14)
self.assertEqual(motif.instances[14].length, 14)
self.assertEqual(motif.instances[15].length, 14)
self.assertEqual(motif.instances[16].length, 14)
self.assertEqual(motif.instances[17].length, 14)
self.assertEqual(motif.instances[18].length, 14)
self.assertEqual(motif.instances[19].length, 14)
self.assertEqual(motif.instances[20].length, 14)
self.assertEqual(motif.instances[0].start, 254)
self.assertEqual(motif.instances[1].start, 258)
self.assertEqual(motif.instances[2].start, 162)
self.assertEqual(motif.instances[3].start, 66)
self.assertEqual(motif.instances[4].start, 278)
self.assertEqual(motif.instances[5].start, 190)
self.assertEqual(motif.instances[6].start, 55)
self.assertEqual(motif.instances[7].start, 114)
self.assertEqual(motif.instances[8].start, 172)
self.assertEqual(motif.instances[9].start, 330)
self.assertEqual(motif.instances[10].start, 126)
self.assertEqual(motif.instances[11].start, 268)
self.assertEqual(motif.instances[12].start, 220)
self.assertEqual(motif.instances[13].start, 229)
self.assertEqual(motif.instances[14].start, 330)
self.assertEqual(motif.instances[15].start, 239)
self.assertEqual(motif.instances[16].start, 121)
self.assertEqual(motif.instances[17].start, 362)
self.assertEqual(motif.instances[18].start, 107)
self.assertEqual(motif.instances[19].start, 155)
self.assertEqual(motif.instances[20].start, 180)
self.assertEqual(str(motif.instances[0]), "INYEKLTEFILKCQ")
self.assertEqual(str(motif.instances[1]), "IDREKLRSFILACQ")
self.assertEqual(str(motif.instances[2]), "INVEKAIEFVLSCM")
self.assertEqual(str(motif.instances[3]), "MNKEEILVFIKSCQ")
self.assertEqual(str(motif.instances[4]), "INVEKLLEWSSARQ")
self.assertEqual(str(motif.instances[5]), "IDTEKLLGYIMSQQ")
self.assertEqual(str(motif.instances[6]), "FVKEEVISFVLSCW")
self.assertEqual(str(motif.instances[7]), "INVDKVVAYVQSLQ")
self.assertEqual(str(motif.instances[8]), "INREKLLQYLYSLK")
self.assertEqual(str(motif.instances[9]), "FNKHALRDYILYCC")
self.assertEqual(str(motif.instances[10]), "LDKRSLARFVSKCQ")
self.assertEqual(str(motif.instances[11]), "LNLKSLLQWVTSRQ")
self.assertEqual(str(motif.instances[12]), "DLFEGTAEWIARCQ")
self.assertEqual(str(motif.instances[13]), "ELTEGVLNYLKNCQ")
self.assertEqual(str(motif.instances[14]), "FHQQALQEYILMCC")
self.assertEqual(str(motif.instances[15]), "KFKEDTITWLLHRQ")
self.assertEqual(str(motif.instances[16]), "IVATDVCQFLELCQ")
self.assertEqual(str(motif.instances[17]), "IPQEIFNDFSKRCC")
self.assertEqual(str(motif.instances[18]), "DRKVRLISFIRGNQ")
self.assertEqual(str(motif.instances[19]), "EVVDPAVDFVLKCY")
self.assertEqual(str(motif.instances[20]), "IDRKGIYQWLISLK")
handle.close()
class TestMAST(unittest.TestCase):
def test_mast_parser_1(self):
"""Test if Motif can parse MAST output files (first test)
"""
from Bio.Alphabet import IUPAC
from Bio.Motif import MAST
handle = open("Motif/mast.dna.oops.txt")
record = MAST.read(handle)
self.assertEqual(record.version, "3.0")
self.assertEqual(record.database, "INO_up800.s")
self.assertEqual(record.alphabet, IUPAC.unambiguous_dna)
self.assertEqual(len(record.motifs), 2)
self.assertEqual(record.motifs[0].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(record.motifs[0].length, 12)
self.assertEqual(record.motifs[0].name, "1")
self.assertEqual(record.motifs[1].alphabet, IUPAC.unambiguous_dna)
self.assertEqual(record.motifs[1].length, 10)
self.assertEqual(record.motifs[1].name, "2")
self.assertEqual(len(record.sequences), 7)
self.assertEqual(record.sequences[0], "ACC1")
self.assertEqual(record.sequences[1], "CHO1")
self.assertEqual(record.sequences[2], "INO1")
self.assertEqual(record.sequences[3], "FAS1")
self.assertEqual(record.sequences[4], "OPI3")
self.assertEqual(record.sequences[5], "CHO2")
self.assertEqual(record.sequences[6], "FAS2")
self.assertEqual(record.diagrams["ACC1"], "82_[+1]_137_[+2]_559")
self.assertEqual(record.diagrams["CHO1"], "152_[+2]_396_[-2]_42_[+1]_17_[+1]_149")
self.assertEqual(record.diagrams["INO1"], "282_[-2]_327_[-1]_55_[+1]_102")
self.assertEqual(record.diagrams["FAS1"], "43_[+2]_41_[+1]_694")
self.assertEqual(record.diagrams["OPI3"], "185_[-2]_144_[+1]_449")
self.assertEqual(record.diagrams["CHO2"], "353_[+1]_47_[-2]_378")
self.assertEqual(record.diagrams["FAS2"], "184_[-2]_372_[+1]_222")
handle.close()
def test_mast_parser_2(self):
"""Test if Motif can parse MAST output files (second test)
"""
from Bio.Alphabet import IUPAC
from Bio.Motif import MAST
handle = open("Motif/mast.protein.oops.txt")
record = MAST.read(handle)
self.assertEqual(record.version, "3.0")
self.assertEqual(record.database, "adh.s")
self.assertEqual(record.alphabet, IUPAC.protein)
self.assertEqual(len(record.motifs), 2)
self.assertEqual(record.motifs[0].alphabet, IUPAC.protein)
self.assertEqual(record.motifs[0].length, 29)
self.assertEqual(record.motifs[0].name, "1")
self.assertEqual(record.motifs[1].alphabet, IUPAC.protein)
self.assertEqual(record.motifs[1].length, 29)
self.assertEqual(record.motifs[1].name, "2")
self.assertEqual(len(record.sequences), 33)
self.assertEqual(record.sequences[0], "BUDC_KLETE")
self.assertEqual(record.sequences[1], "YRTP_BACSU")
self.assertEqual(record.sequences[2], "AP27_MOUSE")
self.assertEqual(record.sequences[3], "HDE_CANTR")
self.assertEqual(record.sequences[4], "HDHA_ECOLI")
self.assertEqual(record.sequences[5], "DHII_HUMAN")
self.assertEqual(record.sequences[6], "FIXR_BRAJA")
self.assertEqual(record.sequences[7], "DHGB_BACME")
self.assertEqual(record.sequences[8], "NODG_RHIME")
self.assertEqual(record.sequences[9], "RIDH_KLEAE")
self.assertEqual(record.sequences[10], "YINL_LISMO")
self.assertEqual(record.sequences[11], "DHMA_FLAS1")
self.assertEqual(record.sequences[12], "HMTR_LEIMA")
self.assertEqual(record.sequences[13], "2BHD_STREX")
self.assertEqual(record.sequences[14], "ENTA_ECOLI")
self.assertEqual(record.sequences[15], "DHB2_HUMAN")
self.assertEqual(record.sequences[16], "BDH_HUMAN")
self.assertEqual(record.sequences[17], "BA72_EUBSP")
self.assertEqual(record.sequences[18], "FVT1_HUMAN")
self.assertEqual(record.sequences[19], "GUTD_ECOLI")
self.assertEqual(record.sequences[20], "DHB3_HUMAN")
self.assertEqual(record.sequences[21], "3BHD_COMTE")
self.assertEqual(record.sequences[22], "LIGD_PSEPA")
self.assertEqual(record.sequences[23], "DHES_HUMAN")
self.assertEqual(record.sequences[24], "RFBB_NEIGO")
self.assertEqual(record.sequences[25], "BPHB_PSEPS")
self.assertEqual(record.sequences[26], "YURA_MYXXA")
self.assertEqual(record.sequences[27], "PCR_PEA")
self.assertEqual(record.sequences[28], "DHCA_HUMAN")
self.assertEqual(record.sequences[29], "ADH_DROME")
self.assertEqual(record.sequences[30], "MAS1_AGRRA")
self.assertEqual(record.sequences[31], "FABI_ECOLI")
self.assertEqual(record.sequences[32], "CSGA_MYXXA")
self.assertEqual(record.diagrams["BUDC_KLETE"], "2_[2]_120_[1]_61")
self.assertEqual(record.diagrams["YRTP_BACSU"], "6_[2]_119_[1]_55")
self.assertEqual(record.diagrams["AP27_MOUSE"], "7_[2]_112_[1]_67")
self.assertEqual(record.diagrams["HDE_CANTR"], "8_[2]_125_[1]_131_[2]_115_[1]_411")
self.assertEqual(record.diagrams["HDHA_ECOLI"], "11_[2]_74_[1]_15_[1]_68")
self.assertEqual(record.diagrams["DHII_HUMAN"], "34_[2]_119_[1]_81")
self.assertEqual(record.diagrams["FIXR_BRAJA"], "36_[2]_123_[1]_61")
self.assertEqual(record.diagrams["DHGB_BACME"], "7_[2]_123_[1]_74")
self.assertEqual(record.diagrams["NODG_RHIME"], "6_[2]_116_[1]_65")
self.assertEqual(record.diagrams["RIDH_KLEAE"], "14_[2]_116_[1]_61")
self.assertEqual(record.diagrams["YINL_LISMO"], "5_[2]_75_[2]_15_[1]_66")
self.assertEqual(record.diagrams["DHMA_FLAS1"], "14_[2]_121_[1]_77")
self.assertEqual(record.diagrams["HMTR_LEIMA"], "6_[2]_157_[1]_66")
self.assertEqual(record.diagrams["2BHD_STREX"], "6_[2]_116_[1]_75")
self.assertEqual(record.diagrams["ENTA_ECOLI"], "5_[2]_109_[1]_76")
self.assertEqual(record.diagrams["DHB2_HUMAN"], "82_[2]_120_[1]_127")
self.assertEqual(record.diagrams["BDH_HUMAN"], "55_[2]_123_[1]_107")
self.assertEqual(record.diagrams["BA72_EUBSP"], "6_[2]_121_[1]_64")
self.assertEqual(record.diagrams["FVT1_HUMAN"], "32_[2]_124_[1]_118")
self.assertEqual(record.diagrams["GUTD_ECOLI"], "2_[2]_122_[1]_77")
self.assertEqual(record.diagrams["DHB3_HUMAN"], "48_[2]_120_[1]_84")
self.assertEqual(record.diagrams["3BHD_COMTE"], "6_[2]_115_[1]_74")
self.assertEqual(record.diagrams["LIGD_PSEPA"], "6_[2]_121_[1]_120")
self.assertEqual(record.diagrams["DHES_HUMAN"], "2_[2]_50_[2]_44_[1]_144")
self.assertEqual(record.diagrams["RFBB_NEIGO"], "6_[2]_129_[1]_153")
self.assertEqual(record.diagrams["BPHB_PSEPS"], "5_[2]_118_[1]_94")
self.assertEqual(record.diagrams["YURA_MYXXA"], "65_[2]_22_[2]_14_[1]_70")
self.assertEqual(record.diagrams["PCR_PEA"], "25_[1]_32_[2]_284")
self.assertEqual(record.diagrams["DHCA_HUMAN"], "4_[2]_159_[1]_55")
self.assertEqual(record.diagrams["ADH_DROME"], "6_[2]_116_[1]_75")
self.assertEqual(record.diagrams["MAS1_AGRRA"], "245_[2]_74_[1]_14_[1]_56")
self.assertEqual(record.diagrams["FABI_ECOLI"], "6_[2]_123_[1]_75")
self.assertEqual(record.diagrams["CSGA_MYXXA"], "51_[2]_7_[1]_50")
handle.close()
def test_mast_parser_3(self):
"""Test if Motif can parse MAST output files (third test)
"""
from Bio.Alphabet import IUPAC
from Bio.Motif import MAST
handle = open("Motif/mast.protein.tcm.txt")
record = MAST.read(handle)
self.assertEqual(record.version, "3.0")
self.assertEqual(record.database, "farntrans5.s")
self.assertEqual(record.alphabet, IUPAC.protein)
self.assertEqual(len(record.motifs), 2)
self.assertEqual(record.motifs[0].alphabet, IUPAC.protein)
self.assertEqual(record.motifs[0].length, 30)
self.assertEqual(record.motifs[0].name, "1")
self.assertEqual(record.motifs[1].alphabet, IUPAC.protein)
self.assertEqual(record.motifs[1].length, 14)
self.assertEqual(record.motifs[1].name, "2")
self.assertEqual(len(record.sequences), 5)
self.assertEqual(record.sequences[0], "BET2_YEAST")
self.assertEqual(record.sequences[1], "RATRABGERB")
self.assertEqual(record.sequences[2], "CAL1_YEAST")
self.assertEqual(record.sequences[3], "PFTB_RAT")
self.assertEqual(record.sequences[4], "RAM1_YEAST")
self.assertEqual(record.diagrams["BET2_YEAST"], "6_[2]_3_[1]_1_[2]_4_[1]_4_[2]_3_[1]_1_[2]_3_[1]_21_[1]_1_[2]_4_[1]_24")
self.assertEqual(record.diagrams["RATRABGERB"], "65_[2]_3_[1]_1_[2]_3_[1]_1_[2]_3_[1]_18_[1]_1_[2]_4_[1]_26")
self.assertEqual(record.diagrams["CAL1_YEAST"], "125_[2]_50_[2]_1_[1]_4_[2]_22_[1]_22_[1]_5_[2]_1")
self.assertEqual(record.diagrams["PFTB_RAT"], "120_[2]_3_[1]_4_[2]_3_[1]_1_[2]_3_[1]_1_[2]_4_[1]_14_[2]_4_[1]_60")
self.assertEqual(record.diagrams["RAM1_YEAST"], "144_[1]_5_[2]_4_[1]_1_[2]_4_[1]_1_[2]_4_[1]_4_[2]_5_[1]_35_[2]_4")
handle.close()
class MotifTestPWM(unittest.TestCase):
def setUp(self):
import warnings
from Bio import BiopythonExperimentalWarning
warnings.simplefilter('ignore', BiopythonExperimentalWarning)
handle = open("Motif/SRF.pfm")
self.m = Motif.read(handle, "pfm")
handle.close()
self.s = Seq("ACGTGTGCGTAGTGCGT", self.m.alphabet)
def test_simple(self):
"""Test if Motif PWM scoring works."""
counts = self.m.counts
pwm = counts.normalize(pseudocounts=0.25)
pssm = pwm.log_odds()
result = pssm.calculate(self.s)
self.assertEqual(6, len(result))
# The fast C-code in Bio/Motif/_pwm.c stores all results as 32-bit
# floats; the slower Python code in Bio/Motif/_Motif.py uses 64-bit
# doubles. The C-code and Python code results will therefore not be
# exactly equal. Test the first 5 decimal places only to avoid either
# the C-code or the Python code to inadvertently fail this test.
self.assertAlmostEqual(result[0], -29.18363571, places=5)
self.assertAlmostEqual(result[1], -38.3365097, places=5)
self.assertAlmostEqual(result[2], -29.17756271, places=5)
self.assertAlmostEqual(result[3], -38.04542542, places=5)
self.assertAlmostEqual(result[4], -20.3014183, places=5)
self.assertAlmostEqual(result[5], -25.18009186, places=5)
if __name__ == "__main__":
runner = unittest.TextTestRunner(verbosity = 2)
unittest.main(testRunner=runner)
Jump to Line
Something went wrong with that request. Please try again.