def get_analysis_id(self,options): selections=""; where_clause="" if options["INSTRUMENT"]: firstpart, secondpart = add_parameters.selections_conditions("INSTRUMENT", options["INSTRUMENT"], selections); selections="," + firstpart; where_clause+=" and " +secondpart if options["PAIR"]: firstpart, secondpart = add_parameters.selections_conditions("PAIR", options["PAIR"], selections); selections="," + firstpart; where_clause+=" and " +secondpart if options["LANE"]: firstpart, secondpart = add_parameters.selections_conditions("LANE", options["LANE"], selections); selections="," + firstpart; where_clause+=" and " +secondpart if options["BARCODE"]: if os.path.exists(options["BARCODE"]): list_of_barcodes=read_file.read_file(options["BARCODE"]) else: list_of_barcodes=options["BARCODE"] firstpart, secondpart = add_parameters.selections_conditions("BARCODE", list_of_barcodes, selections); selections="," + firstpart; where_clause+=" and " +secondpart if options["SAMPLE_NAME"]: if os.path.exists(options["SAMPLE_NAME"]): list_of_samplenames=read_file.read_file(options["SAMPLE_NAME"]) else: list_of_samplenames=options["SAMPLE_NAME"] firstpart, secondpart = add_parameters.selections_conditions("SAMPLE_NAME", list_of_samplenames, selections); selections="," + firstpart; where_clause+=" and " +secondpart statement = "SELECT analysis_id FROM run WHERE " + where_clause[5:] statement = statement + " GROUP BY analysis_id" return self.execute_and_return(statement)
def get_analysis_id(self, options): selections = "" where_clause = "" if options["INSTRUMENT"]: firstpart, secondpart = add_parameters.selections_conditions( "INSTRUMENT", options["INSTRUMENT"], selections) selections = "," + firstpart where_clause += " and " + secondpart if options["PAIR"]: firstpart, secondpart = add_parameters.selections_conditions( "PAIR", options["PAIR"], selections) selections = "," + firstpart where_clause += " and " + secondpart if options["LANE"]: firstpart, secondpart = add_parameters.selections_conditions( "LANE", options["LANE"], selections) selections = "," + firstpart where_clause += " and " + secondpart if options["BARCODE"]: if os.path.exists(options["BARCODE"]): list_of_barcodes = read_file.read_file(options["BARCODE"]) else: list_of_barcodes = options["BARCODE"] firstpart, secondpart = add_parameters.selections_conditions( "BARCODE", list_of_barcodes, selections) selections = "," + firstpart where_clause += " and " + secondpart if options["SAMPLE_NAME"]: if os.path.exists(options["SAMPLE_NAME"]): list_of_samplenames = read_file.read_file( options["SAMPLE_NAME"]) else: list_of_samplenames = options["SAMPLE_NAME"] firstpart, secondpart = add_parameters.selections_conditions( "SAMPLE_NAME", list_of_samplenames, selections) selections = "," + firstpart where_clause += " and " + secondpart statement = "SELECT analysis_id FROM run WHERE " + where_clause[5:] statement = statement + " GROUP BY analysis_id" return self.execute_and_return(statement)
else: list_of_ids = options["ids"] reports = Reports.Reports(config) tables = reports.get_properties_for_analysis_ids(list_of_ids) display_outputs(tables) reports.disconnect() else: print "Please provide a list of analysis ids which you wish to get the properties" exit(1) elif options["get_barcodes_for_sample_name"]: if options["SAMPLE_NAME"]: if os.path.exists(options["SAMPLE_NAME"]): #read the file list_of_samplenames = read_file.read_file(options["SAMPLE_NAME"]) selections, where_clause = add_parameters.selections_conditions( "sample_name", list_of_samplenames, "") else: selections, where_clause = add_parameters.selections_conditions( "sample_name", options["SAMPLE_NAME"], "") statement = "select distinct run.sample_name, run.barcode from run where " + where_clause + " group by barcode" reports = Reports.Reports(config) tables = reports.get_sample_name_for_barcode(statement) display_outputs(tables) reports.disconnect() else: print "Please provide a sample name to get the barcode for it" exit(1) elif options["get_sample_name_for_barcode"]: if options["BARCODE"]: if os.path.exists(options["BARCODE"]):
if options["ids"]: if os.path.exists(options["ids"]): list_of_ids=read_file.read_file(options["ids"]) else: list_of_ids=options["ids"] reports = Reports.Reports(config);tables=reports.get_properties_for_analysis_ids(list_of_ids); display_outputs(tables); reports.disconnect() else: print "Please provide a list of analysis ids which you wish to get the properties" exit(1) elif options["get_barcodes_for_sample_name"]: if options["SAMPLE_NAME"]: if os.path.exists(options["SAMPLE_NAME"]): #read the file list_of_samplenames=read_file.read_file(options["SAMPLE_NAME"]) selections, where_clause=add_parameters.selections_conditions("sample_name", list_of_samplenames, "") else: selections, where_clause=add_parameters.selections_conditions("sample_name", options["SAMPLE_NAME"], "") statement = "select distinct run.sample_name, run.barcode from run where " + where_clause + " group by barcode" reports = Reports.Reports(config);tables=reports.get_sample_name_for_barcode(statement); display_outputs(tables); reports.disconnect() else: print "Please provide a sample name to get the barcode for it" exit(1) elif options["get_sample_name_for_barcode"]: if options["BARCODE"]: if os.path.exists(options["BARCODE"]): #read the file list_of_barcodes=read_file.read_file(options["BARCODE"]) selections, where_clause=add_parameters.selections_conditions("barcode", list_of_barcodes, "") else: