def test_make_topvariants_report_inputs(self): """ in inputs """ ref = self.REFERENCE gff = self.VARIANTS_GFF # test how_many with self.assertRaises(ValueError): make_topvariants_report(gff, ref, 'foo.json', None, 10, self._output_dir) # test batch size with self.assertRaises(ValueError): make_topvariants_report(gff, ref, 'foo.json', 1, None, self._output_dir)
def test_make_topvariants_report_inputs(self): """ in inputs """ ref = self.REFERENCE gff = self.VARIANTS_GFF # test how_many with self.assertRaises(ValueError): make_topvariants_report(gff, ref, 'foo.json', None, 10, self._output_dir) # test batch size with self.assertRaises(ValueError): make_topvariants_report(gff, ref, 'foo.json', 1, None, self._output_dir)
def test_make_minor_topvariants_report(self): """ Call the main report generation method with minor kwarg==True. Deserialize report, check content. """ ref = self.REFERENCE gff = self.RARE_VARIANTS_GFF make_topvariants_report(gff, ref, 100, 10000, 'rpt.json', self._output_dir, is_minor_variants_rpt=True) # deserialize report s = None with open(os.path.join(self._output_dir, 'rpt.json'), 'r') as f: s = json.load(f) report = dict_to_report(s) self.assertEqual('Frequency', report.tables[0].columns[6].header)
def test_make_minor_topvariants_report(self): """ Call the main report generation method with minor kwarg==True. Deserialize report, check content. """ ref = self.REFERENCE gff = self.RARE_VARIANTS_GFF make_topvariants_report( gff, ref, 100, 10000, 'rpt.json', self._output_dir, is_minor_variants_rpt=True) # deserialize report s = None with open(os.path.join(self._output_dir, 'rpt.json'), 'r') as f: s = json.load(f) report = dict_to_report(s)
def test_make_topvariants_report(self): """ Call the main report generation method. Deserialize report, check content. """ ref = self.REFERENCE gff = self.VARIANTS_GFF make_topvariants_report(gff, ref, 100, 10000, 'rpt.json', self._output_dir) # deserialize report s = None with open(os.path.join(self._output_dir, 'rpt.json'), 'r') as f: s = json.load(f) report = dict_to_report(s)
def test_make_minor_topvariants_report(self): """ Call the main report generation method with minor kwarg==True. Deserialize report, check content. """ ref = self.REFERENCE gff = self.RARE_VARIANTS_GFF make_topvariants_report( gff, ref, 100, 10000, 'rpt.json', self._output_dir, is_minor_variants_rpt=True) # deserialize report s = None with open(os.path.join(self._output_dir, 'rpt.json'), 'r') as f: s = json.load(f) report = dict_to_report(s) validate_report_complete(self, report)
def test_make_topvariants_report(self): """ Call the main report generation method. Deserialize report, check content. """ ref = self.REFERENCE gff = self.VARIANTS_GFF make_topvariants_report(gff, ref, 100, 10000, 'rpt.json', self._output_dir) # deserialize report s = None with open(os.path.join(self._output_dir, 'rpt.json'), 'r') as f: s = json.load(f) report = dict_to_report(s) validate_report_complete(self, report)
def _create_top_variants_report(self): """ Creates and returns a Top Variants report. """ from pbreports.report.top_variants import make_topvariants_report datadir = os.path.join(ROOT_DATA_DIR, 'topvariants') log.info( 'Creating top variants report using datadir {d}'.format(d=datadir)) ref = os.path.join(datadir, 'ecoliK12_pbi_March2013') gff = os.path.join(datadir, 'variants.gff.gz') how_many = 100 batch_sort_size = 10000 report = 'topvariants.json' output_json = os.path.join(self._output_dir, report) make_topvariants_report(gff, ref, how_many, batch_sort_size, report, self._output_dir) return self._deserialize_report(output_json)
def _create_top_variants_report(self): """ Creates and returns a Top Variants report. """ from pbreports.report.top_variants import make_topvariants_report datadir = os.path.join(ROOT_DATA_DIR, 'topvariants') log.info( 'Creating top variants report using datadir {d}'.format(d=datadir)) ref = os.path.join(datadir, 'ecoliK12_pbi_March2013') gff = os.path.join(datadir, 'variants.gff.gz') how_many = 100 batch_sort_size = 10000 report = 'topvariants.json' output_json = os.path.join(self._output_dir, report) make_topvariants_report(gff, ref, how_many, batch_sort_size, report, self._output_dir) return self._deserialize_report(output_json)
def test_make_topvariants_report_input_files(self): """ input gff and ref must be non-null and exist """ ref = self.REFERENCE gff = self.VARIANTS_GFF # test gff with self.assertRaises(PbReportError): make_topvariants_report(None, ref, 'foo.json', 1, 10, self._output_dir) with self.assertRaises(IOError): make_topvariants_report('foo', ref, 'foo.json', 1, 10, self._output_dir) # test ref with self.assertRaises(PbReportError): make_topvariants_report(gff, None, 'foo.json', 1, 10, self._output_dir) with self.assertRaises(IOError): make_topvariants_report(gff, 'foo', 'foo.json', 1, 10, self._output_dir)
def test_make_topvariants_report_input_files(self): """ input gff and ref must be non-null and exist """ ref = self.REFERENCE gff = self.VARIANTS_GFF # test gff with self.assertRaises(PbReportError): make_topvariants_report(None, ref, 'foo.json', 1, 10, self._output_dir) with self.assertRaises(IOError): make_topvariants_report('foo', ref, 'foo.json', 1, 10, self._output_dir) # test ref with self.assertRaises(PbReportError): make_topvariants_report(gff, None, 'foo.json', 1, 10, self._output_dir) with self.assertRaises(IOError): make_topvariants_report(gff, 'foo', 'foo.json', 1, 10, self._output_dir)
def run_report(args): return make_topvariants_report(args.gff, args.reference, args.how_many, args.batch_sort_size, args.report, args.output, True)