Ejemplo n.º 1
0
 def test_merge(self):
     r = Report.merge([
         Report.from_simple_dict("pbcommand_test",
                                 {"n_reads": 50, "n_zmws": 10},
                                 "pbcommand"),
         Report.from_simple_dict("pbcommand_test",
                                 {"n_reads": 250, "n_zmws": 50},
                                 "pbcommand")])
     attr = {a.id: a.value for a in r.attributes}
     self.assertEqual(attr['pbcommand_n_reads'], 300)
     self.assertEqual(attr['pbcommand_n_zmws'], 60)
Ejemplo n.º 2
0
def resolved_tool_contract_runner(rtc):
    opts = rtc.task.options
    # XXX to handle chunking I am simply re-using the old i/N arguments, but
    # embedded in the input pickle instead of passed on the command line
    final_pickle_fn = rtc.task.input_files[2]
    _tmp = cPickle.load(open(final_pickle_fn, 'rb'))
    i_chunk = 0
    n_chunks = 1
    if "__chunk_i" in _tmp:
        i_chunk = _tmp['__chunk_i']
        n_chunks = _tmp['__chunk_n']
        final_pickle_fn = _tmp['pickle_file']
    output_dir = os.path.dirname(final_pickle_fn)
    IceFiles.final_consensus_fa = property(
        lambda self: rtc.task.input_files[1])
    IceFiles.final_pickle_fn = property(lambda self: final_pickle_fn)
    IceFiles.nfl_all_pickle_fn = property(lambda self: rtc.task.input_files[3])
    iceq = IceQuiverRTC(
        root_dir=output_dir,
        subread_set=rtc.task.input_files[0],
        nproc=rtc.task.nproc)
    iceq.validate_inputs()
    iceq.process_chunk_i(i=i_chunk, num_chunks=n_chunks)
    with open(rtc.task.output_files[0], 'w') as f:
        report = Report.from_simple_dict(
            report_id="isoseq_ice_quiver",
            raw_d={'n_chunks': 1},
            namespace="ice_quiver")
        f.write(report.to_json())
    return 0
Ejemplo n.º 3
0
 def test_from_simple_dict(self):
     r = Report.from_simple_dict("pbcommand_test", {"n_reads": 50},
                                 "pbcommand")
     json_dict = json.loads(r.to_json())
     self.assertEqual(json_dict['attributes'], [
         {
             "id": "pbcommand_test.pbcommand_n_reads",
             "name": "n_reads",
             "value": 50
         },
     ])
Ejemplo n.º 4
0
 def test_from_simple_dict(self):
     r = Report.from_simple_dict("pbcommand_test", {"n_reads": 50},
                                 "pbcommand")
     json_dict = json.loads(r.to_json())
     self.assertEqual(json_dict['attributes'], [
         {
             "id": "pbcommand_test.pbcommand_n_reads",
             "name": "n_reads",
             "value": 50
         },
     ])
Ejemplo n.º 5
0
def _write_stats_to_json(stats, output_json):
    with open(output_json, 'w') as w:
        w.write(
            Report.from_simple_dict(report_id="pbcommand_test",
                                    raw_d=stats,
                                    namespace="pb").to_json())
Ejemplo n.º 6
0
def _write_stats_to_json(stats, output_json):
    with open(output_json, "w") as w:
        w.write(Report.from_simple_dict(report_id="pbcommand_test", raw_d=stats, namespace="pb").to_json())