Exemplo n.º 1
0
def test_avoid_matches_with_phage():
    PHAGE_TAXID = "697289"
    collection = GenomeCollection()
    index = collection.get_taxid_bowtie_index_path(PHAGE_TAXID, version="1")
    problem = DnaOptimizationProblem(
        sequence=random_dna_sequence(30, seed=123),
        constraints=[AvoidMatches(bowtie_index=index, match_length=10)],
        logger=None,
    )
    all_breaches = problem.constraints_evaluations().all_locations()
    assert len(all_breaches) == 5
    problem.resolve_constraints()
    assert problem.all_constraints_pass()
def test_get_bowtie_index(tmpdir):
    collection = GenomeCollection(data_dir=str(tmpdir))
    path = collection.get_taxid_bowtie_index_path(PHAGE_TAXID, version="2")
    assert os.path.exists(path + '.1.bt2')
Exemplo n.º 3
0
"""Example of use for AvoidBlastMatches.

In this example we create a 1000bp random sequence, then edit out every match
with E. coli that is 14bp or longer.

"""
from dnachisel import DnaOptimizationProblem, random_dna_sequence, AvoidMatches
from genome_collector import GenomeCollection

# THIS CREATES THE ECOLI BLAST DATABASE ON YOUR MACHINE IF NOT ALREADY HERE

collection = GenomeCollection()
ecoli_index = collection.get_taxid_bowtie_index_path(511145, version="1")

# DEFINE AND SOLVE THE PROBLEM

problem = DnaOptimizationProblem(
    sequence=random_dna_sequence(500, seed=123),
    constraints=[
        AvoidMatches(bowtie_index=ecoli_index, match_length=15, mismatches=1)
    ],
)

print(
    "Constraints validity before optimization\n",
    problem.constraints_text_summary(),
)

print("\nNow resolving the problems\n")
problem.resolve_constraints(final_check=True)