def extract_barcodes(fqfile, lane, nindex=25, casava18=True, offset=101, bclen=6, expected=[], mismatch=True): """Parse the fastq file and extract barcodes. Return a dict structure suitable for upload to StatusDB """ bcx = BarcodeExtractor(fqfile, casava18, offset, bclen) c = Counter(bcx) c = remove_expected(c, expected, mismatch) counts = [] header = ['lane', 'sequence', 'count', 'index_name'] for bc, count in c.most_common(nindex): counts.append( dict( zip(header, [ lane, bc, count, ','.join(map_index_name( bc, int(mismatch))) ]))) return [header, counts]
def test_map_index_name(self): """Map index sequences to names """ # Some test cases from scilifelab.illumina.index_definitions import BASIC_LOOKUP random_keys = [BASIC_LOOKUP.keys()[random.randint(0,len(BASIC_LOOKUP.keys())-1)] for n in xrange(25)] for name in random_keys: self.assertIn(name,map_index_name(BASIC_LOOKUP[name],0), "Exact mapping did not return expected index name")
def extract_barcodes(fqfile, lane, nindex=25, casava18=True, offset=101, bclen=6, expected=[], mismatch=True): """Parse the fastq file and extract barcodes. Return a dict structure suitable for upload to StatusDB """ bcx = BarcodeExtractor(fqfile, casava18, offset, bclen) c = Counter(bcx) c = remove_expected(c,expected,mismatch) counts = [] header = ['lane', 'sequence', 'count', 'index_name'] for bc, count in c.most_common(nindex): counts.append(dict(zip(header, [lane, bc, count, ','.join(map_index_name(bc,int(mismatch)))]))) return [header, counts]
def test_map_index_name(self): """Map index sequences to names """ # Some test cases from scilifelab.illumina.index_definitions import BASIC_LOOKUP random_keys = [ BASIC_LOOKUP.keys()[random.randint(0, len(BASIC_LOOKUP.keys()) - 1)] for n in xrange(25) ] for name in random_keys: self.assertIn(name, map_index_name(BASIC_LOOKUP[name], 0), "Exact mapping did not return expected index name")