def register_sample_annotations(argv=None, register_samples=False, db=REGISTRY_DATABASE, out=sys.stdout): if register_samples: p = argparse.ArgumentParser(description=SAMPLES_DESC) else: p = argparse.ArgumentParser(description=ANNOTATIONS_DESC, epilog=ANNOTATIONS_EPILOG) p.add_argument("run_accession", type=int, help="Run accession number") p.add_argument("sample_table", type=argparse.FileType('r'), help=SAMPLE_TABLE_HELP) args = p.parse_args(argv) sample_table = SampleTable.load(args.sample_table) sample_table.look_up_nextera_barcodes() sample_table.validate() registry = SampleRegistry(db) registry.check_run_accession(args.run_accession) if register_samples: registry.register_samples(args.run_accession, sample_table) registry.register_annotations(args.run_accession, sample_table)
def register_sample_annotations( argv=None, register_samples=False, coredb=REGISTRY_DATABASE, out=sys.stdout): if register_samples: p = argparse.ArgumentParser(description=SAMPLES_DESC) else: p = argparse.ArgumentParser( description=ANNOTATIONS_DESC, epilog=ANNOTATIONS_EPILOG) p.add_argument( "run_accession", type=int, help="Run accession number") p.add_argument( "sample_table", type=argparse.FileType('r'), help=SAMPLE_TABLE_HELP) args = p.parse_args(argv) sample_table = SampleTable.load(args.sample_table) sample_table.look_up_nextera_barcodes() sample_table.validate() registry = SampleRegistry(coredb) registry.check_run_accession(args.run_accession) if register_samples: registry.register_samples(args.run_accession, sample_table) registry.register_annotations(args.run_accession, sample_table)
def test_look_up_nextera_barcodes(self): input_file = io.StringIO(NEXTERA_TSV) t = SampleTable.load(input_file) t.look_up_nextera_barcodes() self.assertEqual(t.recs[1]["BarcodeSequence"], u"ACTCGCTA-TATCCTCT") self.assertEqual(t.validate(), None)
def test_parse(self): input_file = io.StringIO(NORMAL_TSV) t = SampleTable.load(input_file) self.assertEqual(t.recs, self.recs)