Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
 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')
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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')
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
 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))
Ejemplo n.º 7
0
 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))
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 def test02(self):
     flat = flatten(controls.values())
     self.assertTrue(all(isinstance(x, dict) for x in flat))
Ejemplo n.º 10
0
 def test01(self):
     flat = flatten(sample_groups.values())
     self.assertTrue(all(isinstance(x, dict) for x in flat))
Ejemplo n.º 11
0
 def test02(self):
     flat = flatten(controls.values())
     self.assertTrue(all(isinstance(x, dict) for x in flat))
Ejemplo n.º 12
0
 def test01(self):
     flat = flatten(sample_groups.values())
     self.assertTrue(all(isinstance(x, dict) for x in flat))
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
 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))
Ejemplo n.º 15
0
 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))
Ejemplo n.º 16
0
 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)