Exemple #1
0
def test_cudapoa_complex_batch():
    random.seed(2)
    read_len = 500
    ref = ''.join([random.choice(['A', 'C', 'G', 'T']) for _ in range(read_len)])
    num_reads = 100
    mutation_rate = 0.02
    reads = []
    for _ in range(num_reads):
        new_read = ''.join([r if random.random() > mutation_rate else random.choice(['A', 'C', 'G', 'T']) for r in ref])
        reads.append(new_read)

    device = cuda.cuda_get_device()
    free, total = cuda.cuda_get_mem_info(device)
    stream = cuda.CudaStream()
    batch = CudaPoaBatch(1000, 0.9 * free, stream=stream, device_id=device)
    (add_status, seq_status) = batch.add_poa_group(reads)
    batch.generate_poa()

    consensus, coverage, status = batch.get_consensus()

    consensus = consensus[0]
    assert(len(consensus) == len(ref))

    match_ratio = SequenceMatcher(None, ref, consensus).ratio()
    assert(match_ratio == 1.0)
Exemple #2
0
def test_cudaaligner_simple_batch(query, target, cigar):
    """Test valid calculation of alignments by checking cigar strings.
    """
    device = cuda.cuda_get_device()
    stream = cuda.CudaStream()
    batch = CudaAlignerBatch(len(query), len(target), 1, alignment_type="global", stream=stream, device_id=device)
    batch.add_alignment(query, target)
    batch.align_all()
    alignments = batch.get_alignments()

    assert(len(alignments) == 1)
    assert(alignments[0].cigar == cigar)