def test_pipeline_run():
        'It tests that the pipeline runs ok'
        pipeline = 'sanger_with_qual'

        fhand_adaptors = NamedTemporaryFile()
        fhand_adaptors.write(ADAPTORS)
        fhand_adaptors.flush()

        arabidopsis_genes = 'arabidopsis_genes+'

        univec = os.path.join(TEST_DATA_DIR, 'blast', arabidopsis_genes)
        configuration = {'remove_vectors_blastdb': {'vectors': univec},
                         'remove_adaptors': {'adaptors': fhand_adaptors.name}}

        seq_fhand = open(os.path.join(TEST_DATA_DIR, 'seq.fasta'), 'r')
        qual_fhand = open(os.path.join(TEST_DATA_DIR, 'qual.fasta'), 'r')

        seq_iter = seqs_in_file(seq_fhand, qual_fhand)

        filtered_seq_iter = _pipeline_builder(pipeline, seq_iter,
                                              configuration)

        seq_list = list(filtered_seq_iter)
        assert 'CGAtcgggggg' in str(seq_list[0].seq)
        assert len(seq_list) == 6
def main():
    'The main part of the script'
    in_fhands, out_fhand, pipeline, libraries = set_parameters()

    #get seqvars from sam pileup
    seq_vars_with_context = snv_contexts_in_sam_pileup(in_fhands,
                                                       libraries=libraries)

    #filter/clean seq_vars
    if pipeline is not None:
        seq_vars_with_context = _pipeline_builder(pipeline, seq_vars_with_context)
    #remove context to the snv iterator
    #print seq_vars_with_context.next()

    seq_vars = (snv[0] for snv in seq_vars_with_context if snv is not None)

    for snv in seq_vars:
        if snv is not None:
            out_fhand.write(repr(snv))