コード例 #1
0
def test_check_ensembl_id():
    with TemporaryDirectory() as tmpdir:
        seqs = SequenceData([FASTA_PATH],
                            require_ensembl_ids=True,
                            cache_directory_path=tmpdir)
        with assert_raises(ValueError):
            seqs.get("WeirdID")
コード例 #2
0
def test_check_ensembl_id():
    with TemporaryDirectory() as tmpdir:
        seqs = SequenceData(
            FASTA_PATH,
            require_ensembl_ids=True,
            cache_directory_path=tmpdir)
        with assert_raises(ValueError):
            seqs.get("WeirdID")
コード例 #3
0
def test_sequence_type():
    with TemporaryDirectory() as tmpdir:
        seqs_dna = SequenceData([FASTA_PATH], cache_directory_path=tmpdir)
        seq = seqs_dna.get("ENSMUST00000138942")
        assert seq is not None, \
            "Failed to find sequence for ENSMUST00000138942"
        assert isinstance(seq, str), \
            "Wrong sequence type, expected %s but got %s" % (str, type(seq))
コード例 #4
0
def test_sequence_type():
    with TemporaryDirectory() as tmpdir:
        seqs_dna = SequenceData(
            FASTA_PATH,
            cache_directory_path=tmpdir)
        seq = seqs_dna.get("ENSMUST00000138942")
        assert seq is not None, \
            "Failed to find sequence for ENSMUST00000138942"
        assert isinstance(seq, str), \
            "Wrong sequence type, expected %s but got %s" % (str, type(seq))
コード例 #5
0
def test_clear_cache():
    with TemporaryDirectory() as tmpdir:
        seqs = SequenceData(FASTA_PATH, cache_directory_path=tmpdir)
        assert not seqs._fasta_dictionary, \
            "Expected _fasta_dictionary to load lazily"

        seqs._load_or_create_fasta_dictionary_pickle()
        assert len(seqs._fasta_dictionary) > 0, \
            "FASTA dictionary didn't get created"

        seqs.clear_cache()
        assert not seqs._fasta_dictionary, \
            "Expected FASTA dictionary to be empty after clear_cache()"
        assert not exists(seqs.fasta_dictionary_pickle_path), \
            "Cached pickle file should have been deleted"

        seqs._load_or_create_fasta_dictionary_pickle()
        assert exists(seqs.fasta_dictionary_pickle_path), \
            "Cached pickle file should have been created"
コード例 #6
0
def test_sequence_type():
    with TemporaryDirectory() as tmpdir:
        seqs_dna = SequenceData(FASTA_PATH,
                                sequence_type=DNA,
                                cache_directory_path=tmpdir)
        seq = seqs_dna.get("ENSMUST00000138942")
        assert isinstance(seq, DNA)

    with TemporaryDirectory() as tmpdir:
        seqs_str = SequenceData(FASTA_PATH,
                                sequence_type=str,
                                cache_directory_path=tmpdir)
        seq = seqs_str.get("ENSMUST00000138942")
        assert isinstance(seq, str)
コード例 #7
0
def test_clear_cache():
    with TemporaryDirectory() as tmpdir:
        seqs = SequenceData(FASTA_PATH, cache_directory_path=tmpdir)
        assert not seqs._fasta_dictionary, \
            "Expected _fasta_dictionary to load lazily"

        seqs._load_or_create_fasta_dictionary_pickle()
        assert len(seqs._fasta_dictionary) > 0, \
            "FASTA dictionary didn't get created"

        seqs.clear_cache()
        assert not seqs._fasta_dictionary, \
            "Expected FASTA dictionary to be empty after clear_cache()"
        assert not exists(seqs.fasta_dictionary_pickle_path), \
            "Cached pickle file should have been deleted"

        seqs._load_or_create_fasta_dictionary_pickle()
        assert exists(seqs.fasta_dictionary_pickle_path), \
            "Cached pickle file should have been created"
コード例 #8
0
def test_missing_sequence():
    with TemporaryDirectory() as tmpdir:
        seqs = SequenceData([FASTA_PATH], cache_directory_path=tmpdir)
        seq = seqs.get("NotInFasta")
        assert seq is None, "Should get None back for missing sequence"
コード例 #9
0
def test_missing_sequence():
    with TemporaryDirectory() as tmpdir:
        seqs = SequenceData(FASTA_PATH, cache_directory_path=tmpdir)
        seq = seqs.get("NotInFasta")
        assert seq is None, "Should get None back for missing sequence"