Ejemplo n.º 1
0
 def testGetLocation02(self):
     """
     Tests integer arguments
     """
     loc = get_location(1, 1, 100)
     self.assertEquals(loc, 'chr1:1-100')
     loc = get_location(1, 1, 1)
     self.assertEquals(loc, 'chr1:1')
Ejemplo n.º 2
0
 def testGetLocation01(self):
     """
     Tests string arguments
     """
     loc = get_location('1', '1', '100')
     self.assertEquals(loc, 'chr1:1-100')
     loc = get_location('1', '1', '1')
     self.assertEquals(loc, 'chr1:1')
Ejemplo n.º 3
0
 def testGetLocation02(self):
     """
     Tests integer arguments
     """
     loc = ann.get_location(1, 1, 100)
     self.assertEquals(loc, 'chr1:1-100')
     loc = ann.get_location(1, 1, 1)
     self.assertEquals(loc, 'chr1:1')
Ejemplo n.º 4
0
 def testGetLocation01(self):
     """
     Tests string arguments
     """
     loc = ann.get_location('1', '1', '100')
     self.assertEquals(loc, 'chr1:1-100')
     loc = ann.get_location('1', '1', '1')
     self.assertEquals(loc, 'chr1:1')
Ejemplo n.º 5
0
def map_headers(fname, header_ids, variant_idx):
    """
    Gets header(s) and info from each file
    """
    # dict mapping variant keys to columns
    with open(fname, 'rU') as infile:
        reader = csv.reader(infile, delimiter='\t')
        for row in reader:

            #adds the value from each position (2,3,4,5,6) to the variant_id
            variant_id = tuple(row[i] for i in variant_idx)

            #create dict of variants {2:'chr', 3:'start', 4:'stop, 5:'ref', 6:'var'}
            variant_dict = dict(zip(variant_headers, variant_id))

            #create dict of data from this file; key is included only
            #if value is not the empty string
            data = dict((key, row[i]) for i, key in header_ids.items() if row[i].strip())
            data['Position'] = get_location(**variant_dict)

            yield (variant_id, dict(data, **variant_dict))
Ejemplo n.º 6
0
def map_headers(fname, header_ids, variant_idx):
    """
    Gets header(s) and info from each file
    """
    # dict mapping variant keys to columns
    with open(fname, 'rU') as infile:
        reader = csv.reader(infile, delimiter='\t')
        for row in reader:

            #adds the value from each position (2,3,4,5,6) to the variant_id
            variant_id = tuple(row[i] for i in variant_idx)

            #create dict of variants {2:'chr', 3:'start', 4:'stop, 5:'ref', 6:'var'}
            variant_dict = dict(zip(variant_headers, variant_id))

            #create dict of data from this file; key is included only
            #if value is not the empty string
            data = dict((key, row[i]) for i, key in header_ids.items()
                        if row[i].strip())
            data['Position'] = get_location(**variant_dict)

            yield (variant_id, dict(data, **variant_dict))