undetermined_dir = os.path.abspath(args.undetermined_dir) # Set up barcode data barcodes = [] for barcode_info in args.barcode_info: name,barcode,lane = barcode_info.split(':') print "Assigning barcode '%s' in lane %s to %s" % (barcode,lane,name) barcodes.append({ 'name': name, 'index': barcode, 'matcher': BarcodeMatcher(barcode), 'lane': int(lane)}) # Read from sample sheet (if supplied) if args.sample_sheet is not None: print "Reading data from sample sheet %s" % args.sample_sheet sample_sheet = IlluminaData.CasavaSampleSheet(args.sample_sheet) for line in sample_sheet: name = line['SampleID'] barcode = line['Index'].rstrip('N').rstrip('-').rstrip('N') lane = line['Lane'] print "Assigning barcode '%s' in lane %s to %s" % (barcode,lane,name) barcodes.append({ 'name': name, 'index': barcode, 'matcher': BarcodeMatcher(barcode), 'lane': int(lane) }) if len(barcodes) < 1: p.error("need at least one --barcode and/or --samplesheet assignment") # Collect input files p = IlluminaData.IlluminaProject(undetermined_dir)
logging.warning( "--miseq option no longer necessary; MiSEQ-style sample sheets " "are now converted automatically") # Get input sample sheet file samplesheet = args[0] if not os.path.isfile(samplesheet): logging.error("sample sheet '%s': not found" % samplesheet) sys.exit(1) # Read in the data as CSV data = IlluminaData.get_casava_sample_sheet(samplesheet) # Remove lanes if options.lanes is not None: lanes = parse_lane_expression(options.lanes) print "Keeping lanes %s, removing the rest" % ','.join( [str(x) for x in lanes]) new_data = IlluminaData.CasavaSampleSheet() for line in data: if line['Lane'] in lanes: print "Keeping %s" % line new_data.append(tabdata="%s" % line) data = new_data # Update the SampleID and SampleProject fields for sample_id in options.sample_id: lanes, name = parse_name_expression(sample_id) for line in data: if line['Lane'] in lanes: print "Setting SampleID for lane %d: '%s'" % (line['Lane'], name) line['SampleID'] = name # Update the SampleProject field for sample_project in options.sample_project:
# Set up barcode data barcodes = [] for barcode_info in options.barcode_info: name, barcode, lane = barcode_info.split(':') print "Assigning barcode '%s' in lane %s to %s" % (barcode, lane, name) barcodes.append({ 'name': name, 'index': barcode, 'matcher': BarcodeMatcher(barcode), 'lane': int(lane) }) # Read from sample sheet (if supplied) if options.sample_sheet is not None: print "Reading data from sample sheet %s" % options.sample_sheet sample_sheet = IlluminaData.CasavaSampleSheet(options.sample_sheet) for line in sample_sheet: name = line['SampleID'] barcode = line['Index'].rstrip('N').rstrip('-').rstrip('N') lane = line['Lane'] print "Assigning barcode '%s' in lane %s to %s" % (barcode, lane, name) barcodes.append({ 'name': name, 'index': barcode, 'matcher': BarcodeMatcher(barcode), 'lane': int(lane) }) if len(barcodes) < 1: p.error("need at least one --barcode and/or --samplesheet assignment")