def test_string_representation(self): from tinyfasta import FastaRecord fasta_record = FastaRecord(">seq101|testing\n") fasta_record.add_sequence_line("atta\n") fasta_record.add_sequence_line("TAAT") self.assertEqual(str(fasta_record), '\n'.join([">seq101|testing", "atta", "TAAT"]))
def test_seqence_contains_function_no_file(self): from tinyfasta import FastaRecord fasta_record = FastaRecord(">seq101|testing\n") fasta_record.add_sequence_line("AAAT") fasta_record.add_sequence_line("TAAA") self.assertTrue(fasta_record.sequence.contains("ATTA")) self.assertFalse(fasta_record.sequence.contains("ACCA"))
def test_seqence_contains_function_with_regex_no_file(self): import re regex_match = re.compile(r"A[T]{2}A") regex_no_match = re.compile(r"A[T]{3}A") from tinyfasta import FastaRecord fasta_record = FastaRecord(">seq101|testing\n") fasta_record.add_sequence_line("AAAT") fasta_record.add_sequence_line("TAAA") self.assertTrue(fasta_record.sequence.contains(regex_match)) self.assertFalse(fasta_record.sequence.contains(regex_no_match))
def test_create_fasta_record(self): from tinyfasta import FastaRecord description = ">seq101|testing" sequence = "ATCG"*30 fasta_record = FastaRecord.create(description, sequence) self.assertEqual(str(fasta_record), """>seq101|testing ATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCG ATCGATCGATCGATCGATCGATCGATCGATCGATCGATCG""")
def test_create_fasta_record(self): from tinyfasta import FastaRecord description = ">seq101|testing" sequence = "ATCG" * 30 fasta_record = FastaRecord.create(description, sequence) self.assertEqual( str(fasta_record), """>seq101|testing ATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCG ATCGATCGATCGATCGATCGATCGATCGATCGATCGATCG""")
def test_update_description(self): from tinyfasta import FastaRecord description = FastaRecord.Description(">seq101|testing\n") self.assertEqual(str(description), ">seq101|testing") description.update(">seq102|testing\n") self.assertEqual(str(description), ">seq102|testing") description.update(">seq103|testing") self.assertEqual(str(description), ">seq103|testing") description.update(">seq104|testing") self.assertEqual(str(description), ">seq104|testing")
def test_Description_initialisation(self): from tinyfasta import FastaRecord description = FastaRecord.Description(">seq101|testing\n") self.assertTrue(isinstance(description, FastaRecord.Description))
def test_FastaRecord_initialisation(self): from tinyfasta import FastaRecord fasta_record = FastaRecord(">seq101|testing\n") self.assertTrue(isinstance(fasta_record, FastaRecord))
def test_len(self): from tinyfasta import FastaRecord fasta_record = FastaRecord(">seq101|testing\n") fasta_record.add_sequence_line("atta\n") fasta_record.add_sequence_line("TAAT") self.assertEqual(len(fasta_record), 8)
def test_description(self): from tinyfasta import FastaRecord fasta_record = FastaRecord(">seq101|testing\n") self.assertEqual(str(fasta_record.description), ">seq101|testing")
def test_str(self): from tinyfasta import FastaRecord description = FastaRecord.Description(">seq101|testing\n") self.assertEqual(str(description), ">seq101|testing")
def test_content(self): from tinyfasta import FastaRecord description = FastaRecord.Description(">seq101|testing\n") self.assertEqual(description._content, ">seq101|testing")
def test_Description_initialisation_withount_leading_arrow(self): from tinyfasta import FastaRecord description = FastaRecord.Description("seq101|testing\n") self.assertEqual(str(description), ">seq101|testing")
def test_len_when_empty(self): from tinyfasta import FastaRecord fasta_record = FastaRecord(">seq101|testing\n") self.assertEqual(len(fasta_record), 0)
def test_seqence_type(self): from tinyfasta import FastaRecord, Sequence fasta_record = FastaRecord(">seq101|testing\n") self.assertTrue(isinstance(fasta_record.sequence, Sequence))
def test_description_type(self): from tinyfasta import FastaRecord fasta_record = FastaRecord(">seq101|testing\n") self.assertTrue( isinstance(fasta_record.description, FastaRecord.Description))