def main(): """ :return: """ parser = argparse.ArgumentParser( description='Convert BAM Read Groups to GDC Read Group Nodes') subparsers = parser.add_subparsers(dest='command') parser.add_argument('-d', '--debug', action='store_const', const=logging.DEBUG, dest='level', help='Enable debug logging.') parser.set_defaults(level=logging.INFO) parser.add_argument('-v', '--version', action='store_true', required=False, help='Output program version.') parser_bam = subparsers.add_parser( 'bam-mode', help='using a BAM file, write GDC Read Group nodes') parser_bam.add_argument('-b', '--bam-path', action='store', required=True, help='BAM file') parser_bam.add_argument('-f', '--output-format', action='store', choices=['json', 'tsv'], default='json', required=False) parser_template = subparsers.add_parser( 'template-mode', help='write template with two Read Groups') parser_template.add_argument('-f', '--output-format', action='store', choices=['json', 'tsv'], default='json', required=False) args = parser.parse_args() logger = setup_logging(args) if args.command: if args.command == 'bam-mode': validate_input(args.bam_path, logger) out_file = extract_readgroup(args.bam_path, args.output_format, logger) logger.info('\nwrote {}'.format(out_file)) elif args.command == 'template-mode': out_file = generate_template(args.output_format, logger) logger.info('\nwrote {}'.format(out_file)) elif args.version: output_version(logger) else: parser.print_help() return
def test(self): try: self.testjson = extract_readgroup.extract_readgroup(self.bam, 'json', self.logger) except NotABamError: pass else: self.logger.error('Input File\n\t{}\ndid not raise `NotABamError`'.format(self.bam)) raise RuntimeError
def test(self): self.testjson = extract_readgroup.extract_readgroup( self.bam, 'json', self.logger) with open(self.testjson, 'r') as f: testdata = json.load(f) self.assertEqual(self.expecteddata, testdata)