Exemple #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()
Exemple #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')
Exemple #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)
Exemple #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')
Exemple #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()
Exemple #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))
Exemple #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))
Exemple #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)
Exemple #9
0
 def test02(self):
     flat = flatten(controls.values())
     self.assertTrue(all(isinstance(x, dict) for x in flat))
Exemple #10
0
 def test01(self):
     flat = flatten(sample_groups.values())
     self.assertTrue(all(isinstance(x, dict) for x in flat))
Exemple #11
0
 def test02(self):
     flat = flatten(controls.values())
     self.assertTrue(all(isinstance(x, dict) for x in flat))
Exemple #12
0
 def test01(self):
     flat = flatten(sample_groups.values())
     self.assertTrue(all(isinstance(x, dict) for x in flat))
Exemple #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)
Exemple #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))
Exemple #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))
Exemple #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)