Ejemplo n.º 1
0
def sample_ids2intron_ids_from_db(sample_ids):
    select = 'SELECT snaptron_ids FROM by_sample_id WHERE sample_id in'
    found_snaptron_ids = set()
    results = snaputil.retrieve_from_db_by_ids(sc,select,sample_ids)
    #ids = [x[0] for x in results]
    for snaptron_ids in results:
        found_snaptron_ids.update(set(snaptron_ids[0].split(',')))
    #s1=','.join(ids)
    #found_snaptron_ids.update(s1.split(','))
    if '' in found_snaptron_ids:
        found_snaptron_ids.remove('')
    return found_snaptron_ids
Ejemplo n.º 2
0
def sample_ids2intron_ids_from_db(sample_ids):
    select = 'SELECT snaptron_ids FROM by_sample_id WHERE sample_id in'
    found_snaptron_ids = set()
    results = snaputil.retrieve_from_db_by_ids(sc,select,sample_ids)
    #ids = [x[0] for x in results]
    for snaptron_ids in results:
        found_snaptron_ids.update(set(snaptron_ids[0].split(',')))
    #s1=','.join(ids)
    #found_snaptron_ids.update(s1.split(','))
    if '' in found_snaptron_ids:
        found_snaptron_ids.remove('')
    return found_snaptron_ids
Ejemplo n.º 3
0
def search_introns_by_ids(ids,rquery,filtering=False,region_args=default_region_args):
    ra = region_args
    select = 'SELECT * from intron WHERE snaptron_id in'
    found_snaptron_ids = set()
    if len(ids) == 0:
        return (set(),set())
    results = snaputil.retrieve_from_db_by_ids(snc,select,ids)
    #now get methods for 1) header output and 2) intron output (depending on request)
    (header_method,streamer_method) = return_formats[ra.return_format]
    header_method(sys.stdout,region_args=ra,interval=ra.coordinate_string)
    #exit early as we only want the ucsc_url
    if ra.return_format == UCSC_URL:
        return (set(),set())
    for intron in results:
        found_snaptron_ids.update(set([str(intron[0])])) 
        if ra.stream_back:
            streamer_method(sys.stdout,None,intron,ra)
    return (found_snaptron_ids,set())
Ejemplo n.º 4
0
def search_introns_by_ids(ids,rquery,filtering=False,region_args=default_region_args):
    #TODO also process rquery as part of the SQL
    ra = region_args
    select = 'SELECT * from intron WHERE snaptron_id in'
    found_snaptron_ids = set()
    if len(ids) == 0:
        return (set(),set())
    results = snaputil.retrieve_from_db_by_ids(snc,select,ids)
    #now get methods for 1) header output and 2) intron output (depending on request)
    (header_method,streamer_method) = snaputil.return_formats[ra.return_format]
    header_method(sys.stdout,region_args=ra,interval=ra.coordinate_string)
    #exit early as we only want the ucsc_url
    if ra.return_format == UCSC_URL:
        return (set(),set())
    for intron in results:
        found_snaptron_ids.update(set([str(intron[0])])) 
        if ra.stream_back:
            streamer_method(sys.stdout,None,intron,ra)
    return (found_snaptron_ids,set())
Ejemplo n.º 5
0
def get_samples_for_snaptron_ids(ids):
    select = 'SELECT snaptron_id,samples,read_coverage_by_sample FROM intron where snaptron_id in'
    results = snaputil.retrieve_from_db_by_ids(sc,select,ids)
    return results