Esempio n. 1
0
def main():
    options, args = interface()
    conf = ConfigParser.ConfigParser()
    conf.read(options.input)
    # create a temporary table in memory for the results
    if options.keepdb:
        dir, name = os.path.split(options.output)
        name = name.split('.')[0] + '.sqlite'
        db_path = os.path.join(dir, name)
        conn = sqlite3.connect(db_path)
    else:
        conn = sqlite3.connect(':memory:')
    cur = conn.cursor()
    create_database(cur)
    settings = get_primer3_settings()
    # make sure we send it the correct version of primer3
    p3 = primer.Primers(binary='primer3_long')
    # trick the module to think we've actually designed primers
    p3.primers_designed = True
    p3.primers = {0:
        {'PRIMER_LEFT_SEQUENCE':options.left, 'PRIMER_RIGHT_SEQUENCE':options.right}, 
        'metadata':None
        }
    # check normal primers
    p3.check(settings)
    for k in p3.checked_primers:
        if p3.checked_primers[k]:
            p3.checked_primers[k]['SECTION'] = 'None'
            p3.checked_primers[k]['CYCLES'] = 0
            p3.checked_primers[k]['TAG'] = None
            p3.checked_primers[k]['UNMODIFIED'] = 1
            p3.checked_primers[k]['PAIR_HAIRPIN_EITHER'] = 0
            # add some information that will be missing from these
            p3.checked_primers[k]['PRIMER_LEFT_TAG'] = None
            p3.checked_primers[k]['PRIMER_RIGHT_TAG'] = None
            p3.checked_primers[k]['PRIMER_LEFT_TAG_COMMON_BASES'] = None
            p3.checked_primers[k]['PRIMER_RIGHT_TAG_COMMON_BASES'] = None
            for p in ['PRIMER_LEFT_PROBLEMS', 'PRIMER_RIGHT_PROBLEMS']:
                if p not in p3.checked_primers[k].keys():
                    p3.checked_primers[k][p] = None
                elif 'Hairpin stability too high;' in p3.checked_primers[k][p]:
                    p3.checked_primers[k]['PAIR_HAIRPIN_EITHER'] = 1
            #pdb.set_trace()
            insert_primers(cur, p3.checked_primers[k])
    #f = open(options.input, 'rU')
    # [[name, tag]]
    #tags = [line.strip().split(',') for line in f]
    if not options.section:
        for section in conf.sections():
            tags = get_tag_array(conf.items(section))
            design_and_store_primers(options, cur, section, tags, p3, settings)
    elif options.section:
        tags = get_tag_array(conf.items(options.section))
        design_and_store_primers(options, cur, options.section, tags, p3, settings)
    conn.commit()
    # close the tag input file - it's not needed anymore
    #f.close()
    if options.output:
        write_results(cur, options.output, options.sort_keys)
Esempio n. 2
0
def main():
    options, args = interface()
    conf = ConfigParser.ConfigParser()
    conf.read(options.input)
    adapters = {}
    if not options.section:
        for section in conf.sections():
            tags = get_tag_array(conf.items(section))
            adapters = add_tags_to_adapters(adapters, section, options.fprime, options.tprime, tags, options.revcomp)
    elif options.section:
        tags = get_tag_array(conf.items(options.section))
        adapters = add_tags_to_adapters(adapters, options.section, options.fprime, options.tprime, tags, options.revcomp)
    show_results(adapters, options.suppress)
Esempio n. 3
0
def main():
    options, args = interface()
    conf = ConfigParser.ConfigParser()
    conf.read(options.input)
    adapters = {}
    if not options.section:
        for section in conf.sections():
            tags = get_tag_array(conf.items(section))
            adapters = add_tags_to_adapters(adapters, section, options.fprime,
                                            options.tprime, tags,
                                            options.revcomp)
    elif options.section:
        tags = get_tag_array(conf.items(options.section))
        adapters = add_tags_to_adapters(adapters, options.section,
                                        options.fprime, options.tprime, tags,
                                        options.revcomp)
    show_results(adapters, options.suppress)
def main():
    """main loop"""
    options, arg = interface()
    conf = ConfigParser.ConfigParser()
    conf.read(options.input)
    if options.hamming:
        vector_distance = numpy.vectorize(hammng)
    else:
        vector_distance = numpy.vectorize(levenshtein)
    bad = {}
    if not options.section:
        for section in conf.sections():
            tags = get_tag_array(conf.items(section))
            names = get_name_array(conf.items(section))
            bad = get_section_results(options, bad, tags, section, vector_distance)
    elif options.section:
        tags = get_tag_array(conf.items(options.section))
        names = get_name_array(conf.items(options.section))
        bad = get_section_results(options, bad, tags, options.section, vector_distance)
    if options.minimums:
        print_minimums(conf, names, tags, bad, options.verbose)
    elif options.distances:
        print_distances(conf, options, names, tags, bad, options.verbose)
def main():
    """main loop"""
    options, arg = interface()
    conf = ConfigParser.ConfigParser()
    conf.read(options.input)
    if options.hamming:
        vector_distance = numpy.vectorize(hammng)
    else:
        vector_distance = numpy.vectorize(levenshtein)
    bad = {}
    if not options.section:
        for section in conf.sections():
            tags = get_tag_array(conf.items(section))
            names = get_name_array(conf.items(section))
            bad = get_section_results(options, bad, tags, section, vector_distance)
    elif options.section:
        tags = get_tag_array(conf.items(options.section))
        names = get_name_array(conf.items(options.section))
        bad = get_section_results(options, bad, tags, options.section, vector_distance)
    if options.minimums:
        print_minimums(conf, names, tags, bad, options.verbose)
    elif options.distances:
        print_distances(conf, options, names, tags, bad, options.verbose)
Esempio n. 6
0
def main():
    options, args = interface()
    conf = ConfigParser.ConfigParser()
    conf.read(options.input)
    # create a temporary table in memory for the results
    if options.keepdb:
        dir, name = os.path.split(options.output)
        name = name.split('.')[0] + '.sqlite'
        db_path = os.path.join(dir, name)
        conn = sqlite3.connect(db_path)
    else:
        conn = sqlite3.connect(':memory:')
    cur = conn.cursor()
    create_database(cur)
    settings = get_primer3_settings()
    # make sure we send it the correct version of primer3
    p3 = primer.Primers(binary='primer3_long')
    # trick the module to think we've actually designed primers
    p3.primers_designed = True
    p3.primers = {
        0: {
            'PRIMER_LEFT_SEQUENCE': options.left,
            'PRIMER_RIGHT_SEQUENCE': options.right
        },
        'metadata': None
    }
    # check normal primers
    p3.check(settings)
    for k in p3.checked_primers:
        if p3.checked_primers[k]:
            p3.checked_primers[k]['SECTION'] = 'None'
            p3.checked_primers[k]['CYCLES'] = 0
            p3.checked_primers[k]['TAG'] = None
            p3.checked_primers[k]['UNMODIFIED'] = 1
            p3.checked_primers[k]['PAIR_HAIRPIN_EITHER'] = 0
            # add some information that will be missing from these
            p3.checked_primers[k]['PRIMER_LEFT_TAG'] = None
            p3.checked_primers[k]['PRIMER_RIGHT_TAG'] = None
            p3.checked_primers[k]['PRIMER_LEFT_TAG_COMMON_BASES'] = None
            p3.checked_primers[k]['PRIMER_RIGHT_TAG_COMMON_BASES'] = None
            for p in ['PRIMER_LEFT_PROBLEMS', 'PRIMER_RIGHT_PROBLEMS']:
                if p not in p3.checked_primers[k].keys():
                    p3.checked_primers[k][p] = None
                elif 'Hairpin stability too high;' in p3.checked_primers[k][p]:
                    p3.checked_primers[k]['PAIR_HAIRPIN_EITHER'] = 1
            #pdb.set_trace()
            insert_primers(cur, p3.checked_primers[k])
    #f = open(options.input, 'rU')
    # [[name, tag]]
    #tags = [line.strip().split(',') for line in f]
    if not options.section:
        for section in conf.sections():
            tags = get_tag_array(conf.items(section))
            design_and_store_primers(options, cur, section, tags, p3, settings)
    elif options.section:
        tags = get_tag_array(conf.items(options.section))
        design_and_store_primers(options, cur, options.section, tags, p3,
                                 settings)
    conn.commit()
    # close the tag input file - it's not needed anymore
    #f.close()
    if options.output:
        write_results(cur, options.output, options.sort_keys)