def raise_error_if_unequal(self, sequence_id: pSeq.SequenceID, expected_sequence: str, fasta_provider: FromFile) -> None: for i, expected_symbol in enumerate(expected_sequence): expected_base = pNode.Base(expected_symbol) actual_base = fasta_provider.get_base(sequence_id, i) self.assertEqual(pNode.Base(expected_symbol), actual_base)
def test_2_read_seqeunce_from_cache_instead_downloading(self): fasta_provider = FromNCBI(EmailAddress('*****@*****.**'), use_cache=True) cache_dir_path = pathtools.get_child_path(Path.cwd(), ".fastacache") if cache_dir_path.exists(): shutil.rmtree(cache_dir_path) cache_dir_path.mkdir() sequence_id = pSeq.SequenceID("seq1") fake_sequence = "foo" expected_base = pNode.Base("o") fake_fasta_path = pathtools.get_child_path(cache_dir_path, f"{sequence_id}.fasta") with open(fake_fasta_path, 'w') as fake_fasta_handler: fake_fasta_handler.write(f">{sequence_id} cached\n{fake_sequence}") actual_base = fasta_provider.get_base(sequence_id, 2) self.assertEqual(expected_base, actual_base)
def bid(x): return pNode.Base(x)
def b(x): return pNode.Base(x)