示例#1
0
    def test_read_skip_sequence(self):
        fasta = os.path.join(self.formats_folder, "fasta")

        with easel.SequenceFile(fasta) as f:
            seq = f.read()
            self.assertEqual(seq.name, b"SNRPA_DROME")
            self.assertNotEqual(seq.sequence, "")

        with easel.SequenceFile(fasta) as f:
            seq = f.read(skip_sequence=True)
            self.assertEqual(seq.name, b"SNRPA_DROME")
            self.assertEqual(seq.sequence, "")
示例#2
0
    def test_readformat_genbank(self):
        gbk = os.path.join(self.formats_folder, "genbank")

        # check reading an EMBL file works
        with easel.SequenceFile(gbk, "genbank") as f:
            seq = f.read()
            self.assertNotEqual(seq.accession, b"")

        # check reading an GenBank file without specifying the format works too
        with easel.SequenceFile(gbk) as f:
            seq2 = f.read()
            self.assertNotEqual(seq2.accession, b"")

        # check reading an GenBank file while giving another format fails
        with easel.SequenceFile(gbk, "fasta") as f:
            self.assertRaises(ValueError, f.read)
示例#3
0
    def test_readformat_fasta(self):
        for filename in ["fasta", "fasta.2", "fasta.odd.1"]:
            fasta = os.path.join(self.formats_folder, filename)

            # check reading a FASTA file works
            with easel.SequenceFile(fasta, "fasta") as f:
                seq = f.read()
                self.assertNotEqual(seq.name, b"")

            # check reading a FASTA file without specifying the format works too
            with easel.SequenceFile(fasta) as f:
                seq2 = f.read()
                self.assertNotEqual(seq2.name, b"")

            # check reading a FASTA file while giving another format fails
            with easel.SequenceFile(fasta, "embl") as f:
                self.assertRaises(ValueError, f.read)
示例#4
0
    def test_iter(self):
        fasta = os.path.join(self.formats_folder, "fasta")

        with easel.SequenceFile(fasta) as f:
            seq1, seq2 = list(f)

        self.assertEqual(seq1.name, b"SNRPA_DROME")
        self.assertEqual(seq2.name, b"SNRPA_HUMAN")
示例#5
0
 def test_init_error_unknownformat(self):
     with self.assertRaises(ValueError):
         _file = easel.SequenceFile("file.x", format="nonsense")
示例#6
0
 def test_guess_alphabet(self):
     embl = os.path.join(self.formats_folder, "embl")
     with easel.SequenceFile(embl, "embl") as f:
         self.assertEqual(f.guess_alphabet(), easel.Alphabet.dna())
示例#7
0
 def test_readformat_fasta_error(self):
     fasta = os.path.join(self.formats_folder, "fasta.bad.1")
     with easel.SequenceFile(fasta, "fasta") as f:
         self.assertRaises(ValueError, f.read)