def action(args): controls, sample_groups = get_input(args.infile, split_description=args.split_desc) qadata = qa_from_csv(qafile) matrix = read_matrix(matrix_file) style = "screen" if args.outfile == sys.stdout else "file" outfile = get_outfile(args, label="qa", ext="csv") if args.calculate_ion_ratios: qadata = add_ion_ratios(qadata, controls) # if a single compound is specified, define lambda cond to use as # a filter if args.compound_id: cond = lambda c: c["COMPOUND_id"] == args.compound_id else: cond = lambda c: True # controls compounds = [Compound(c, matrix, **qadata[c["COMPOUND_id"]]) for c in flatten(controls.values()) if cond(c)] display_controls(compounds, outfile=outfile, show_all=args.show_all, message=not args.outcomes_only, style=style) compounds = [Compound(c, matrix, **qadata[c["COMPOUND_id"]]) for c in flatten(sample_groups.values()) if cond(c)] display_specimens(compounds, outfile=outfile, show_all=args.show_all, message=not args.outcomes_only, style=style) if args.outfile is None: outfile.close()
def test01(self): compounds = [Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(patient_sample)] compounds.sort(key = lambda c: c.sort_by_patient()) for cmpnd_id, cmpnds in groupby(compounds, lambda c: c.COMPOUND_id): sample = Sample(cmpnds) self.assertEqual(cmpnd_id, sample.COMPOUND_id) self.assertEqual(sample.type, 'patient')
def test02(self): compounds = [ Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(misc_sample) ] compounds.sort(key=lambda c: c.sort_by_patient()) for cmpnd_id, cmpnds in groupby(compounds, lambda c: c.COMPOUND_id): self.assertRaises(TypeError, Sample, cmpnds)
def test01(self): compounds = [ Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(patient_sample) ] compounds.sort(key=lambda c: c.sort_by_patient()) for cmpnd_id, cmpnds in groupby(compounds, lambda c: c.COMPOUND_id): sample = Sample(cmpnds) self.assertEqual(cmpnd_id, sample.COMPOUND_id) self.assertEqual(sample.type, 'patient')
def action(args): controls, sample_groups = get_input(args.infile, split_description=args.split_desc) qadata = qa_from_csv(qafile) matrix = read_matrix(matrix_file) style = 'screen' if args.outfile == sys.stdout else 'file' outfile = get_outfile(args, label='qa', ext='csv') if args.calculate_ion_ratios: qadata = add_ion_ratios(qadata, controls) # if a single compound is specified, define lambda cond to use as # a filter if args.compound_id: cond = lambda c: c['COMPOUND_id'] == args.compound_id else: cond = lambda c: True # controls compounds = [ Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(controls.values()) if cond(c) ] display_controls(compounds, outfile=outfile, show_all=args.show_all, message=not args.outcomes_only, style=style) compounds = [ Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(sample_groups.values()) if cond(c) ] display_specimens(compounds, outfile=outfile, show_all=args.show_all, message=not args.outcomes_only, style=style) if args.outfile is None: outfile.close()
def test02(self): compounds = [ Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(controls.values()) ] self.assertTrue(all(x.type == 'control' for x in compounds))
def test03(self): compounds = [ Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(compound1) ] self.assertTrue(all(x.type == 'patient' for x in compounds))
def test02(self): compounds = [Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(sample_groups.values())] display_specimens(compounds, sys.stdout, message = False)
def test02(self): flat = flatten(controls.values()) self.assertTrue(all(isinstance(x, dict) for x in flat))
def test01(self): flat = flatten(sample_groups.values()) self.assertTrue(all(isinstance(x, dict) for x in flat))
def test02(self): compounds = [ Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(sample_groups.values()) ] display_specimens(compounds, sys.stdout, message=False)
def test03(self): compounds = [Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(compound1)] self.assertTrue(all(x.type == 'patient' for x in compounds))
def test02(self): compounds = [Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(controls.values())] self.assertTrue(all(x.type == 'control' for x in compounds))
def test02(self): compounds = [Compound(c, matrix, **qadata[c['COMPOUND_id']]) for c in flatten(misc_sample)] compounds.sort(key = lambda c: c.sort_by_patient()) for cmpnd_id, cmpnds in groupby(compounds, lambda c: c.COMPOUND_id): self.assertRaises(TypeError, Sample, cmpnds)