def test__guess_seqtype_from_file_fasta_correct(self): "Test guessing the sequence type from correct fasta contents" with open(get_file_path('melanin.fasta'), 'rU') as h: self.assertEqual("fasta", seqio._guess_seqtype_from_file(h)) h.seek(0) string_seq = h.read() self.assertEqual("fasta", seqio._guess_seqtype_from_file(string_seq))
def test__guess_seqtype_from_file_genbank_no_header(self): "Test guessing the sequence type from a genbank file without header" with open(get_file_path('no_header.gbk'), 'rU') as h: self.assertEqual("genbank", seqio._guess_seqtype_from_file(h)) h.seek(0) string_seq = h.read() self.assertEqual("genbank", seqio._guess_seqtype_from_file(string_seq))
def test__guess_seqtype_from_file_embl_no_header(self): "Test guessing the sequence type from an embl file without header" with open(get_file_path('no_header.embl'), 'rU') as h: self.assertEqual("embl", seqio._guess_seqtype_from_file(h)) h.seek(0) string_seq = h.read() self.assertEqual("embl", seqio._guess_seqtype_from_file(string_seq))
def test_read_fasta_no_header(self): "Test reading a fasta record without header" with open(get_file_path('no_header.fasta'), 'rU') as h: # plain BioPython reading should fail self.assertRaises(ValueError, seqio.read, h) h.seek(0) # robust reading should work record = seqio.read(h, robust=True) self.assertEqual("DUMMY", record.id)
def test_parse_fasta_no_header(self): "Test parsing a fasta record without header" with open(get_file_path('no_header.fasta'), 'rU') as h: # plain BioPython parsing should fail records = list(seqio.parse(h)) self.assertEqual(0, len(records)) h.seek(0) # robust parsing should work records = list(seqio.parse(h, robust=True)) self.assertEqual(1, len(records))
def test_read_fasta_valid(self): "Test reading a valid fasta record" with open(get_file_path('melanin.fasta'), 'rU') as h: record = seqio.read(h) self.assertEqual("AB070938", record.id)
def test_read_embl_valid(self): "Test reading a valid embl record" with open(get_file_path('melanin.embl'), 'rU') as h: record = seqio.read(h) self.assertEqual("AB070938.1", record.id)
def test_parse_fasta_valid(self): "Test parsing a valid fasta record" with open(get_file_path('melanin.fasta'), 'rU') as h: records = list(seqio.parse(h)) self.assertEqual(1, len(records))
def test_parse_genbank_valid(self): "Test parsing a valid genbank record" with open(get_file_path('melanin.gbk'), 'rU') as h: records = list(seqio.parse(h)) self.assertEqual(1, len(records))
def test_parse_genbank_path(self): "Test parsing a gzipped GenBank file specified by path" fname = get_file_path('melanin.gbk.gz') records = list(seqio.parse(fname)) self.assertEqual(1, len(records))
def test_parse_genbank(self): "Test parsing a gzipped GenBank file" with open(get_file_path('melanin.gbk.gz'), 'rb') as h: records = list(seqio.parse(h)) self.assertEqual(1, len(records))
def test_read_genbank_path(self): "Test reading a gzipped GenBank file specified by path" fname = get_file_path('melanin.gbk.gz') record = seqio.read(fname) self.assertEqual("AB070938.1", record.id)
def test_read_genbank(self): "Test reading a gzipped GenBank file" with open(get_file_path('melanin.gbk.gz'), 'rb') as h: record = seqio.read(h) self.assertEqual("AB070938.1", record.id)
def test__guess_seqtype_from_file_fasta_no_header_lower_case(self): "Test guessing the sequence type from a lower case fasta file without header" with open(get_file_path('no_header.fasta'), 'rU') as h: string_seq = h.read().lower() self.assertEqual("fasta", seqio._guess_seqtype_from_file(string_seq))