def save_results(matched, notmatched, badquality, skipped, total, _progress): total = float(total) send_message( save( "matched", "{:,} reads ({:.2f} %)".format(matched, 100 * matched / total), )) send_message( save( "notmatched", "{:,} reads ({:.2f} %)".format(notmatched, 100 * notmatched / total), )) send_message( save( "badquality", "{:,} reads ({:.2f} %)".format(badquality, 100 * badquality / total), )) send_message( save( "skipped", "{:,} reads ({:.2f} %)".format(skipped, 100 * skipped / total), )) send_message(progress(_progress))
def test_string(self): expected = { 'type': 'COMMAND', 'type_data': 'update_output', 'data': {'bar': 'baz'}, } self.assertEqual(save('bar', 'baz'), expected) expected["data"] = {'proc.warning': 'Warning foo'} self.assertEqual(save('proc.warning', 'Warning foo'), expected) expected["data"] = {'number': "0"} self.assertEqual(save('number', '"0"'), expected)
def main(): """Invoke when run directly as a program.""" args = parse_arguments() with open(args.input_file) as infile: data = json.load(infile) if 'expected_format' in data and 'compatible_fragment_ratio' in data: print(save('strandedness', data['expected_format'])) print(save('fragment_ratio', str(round(data['compatible_fragment_ratio'], 2)))) else: print(error("Cannot parse library type information file."))
def main(): """Invoke when run directly as a program.""" args = parse_arguments() with open(args.input_file) as infile: data = json.load(infile) if "expected_format" in data and "compatible_fragment_ratio" in data: send_message(save("strandedness", data["expected_format"])) send_message( save("fragment_ratio", str(round(data["compatible_fragment_ratio"], 2)))) else: send_message(error("Cannot parse library type information file."))
def main(): """Invoke when run directly as a program.""" args = parse_arguments() with open(args.input_file) as infile: data = json.load(infile) if 'expected_format' in data and 'compatible_fragment_ratio' in data: print(save('strandedness', data['expected_format'])) print( save('fragment_ratio', str(round(data['compatible_fragment_ratio'], 2)))) else: print(error("Cannot parse library type information file."))
def test_hash(self, copy_mock): expected = { 'type': 'COMMAND', 'type_data': 'update_output', 'data': {'etc': {'file': 'foo.py'}}, } self.assertEqual(save('etc', '{"file": "foo.py"}'), expected)
def test_quote(self): expected = { 'type': 'COMMAND', 'type_data': 'update_output', 'data': {'foo': '"'}, } self.assertEqual(save('foo', '"'), expected)
def test_number(self): expected = {'type': 'COMMAND', 'type_data': 'update_output', 'data': {'foo': 0}} self.assertEqual(save('foo', '0'), expected)
genes[str(x[0])] = x[1:] return times, genes if file_name[-4:] == ".xls" or file_name[-5:] == ".xlsx": times, genes = import_excel(file_name) else: times, genes = import_table(file_name) etcjson = '{"etc":%s}' % json.dumps({ "genes": genes, "timePoints": times }, separators=(",", ":")) send_message( save( "etc", json.dumps({ "genes": genes, "timePoints": times }, separators=(",", ":")))) zipfile = gzip.GzipFile( filename="", mode="wb", fileobj=open("etc.json.gz", "wb"), mtime=0, ) zipfile.write(etcjson.encode("utf-8"))
def test_string(self): self.assertEqual(save('bar', 'baz'), '{"bar": "baz"}') self.assertEqual(save('proc.warning', 'Warning foo'), '{"proc.warning": "Warning foo"}') self.assertEqual(save('number', '"0"'), '{"number": "0"}')
def test_hash(self): self.assertEqual(save('etc', '{"file": "foo.py"}'), '{"etc": {"file": "foo.py"}}')
def to_output(self, value): """Convert value to process output format.""" return json.loads(resolwe_runtime_utils.save(self.name, value))
def test_number(self): self.assertEqual(save('foo', '0'), '{"foo": 0}')
def test_quote(self): self.assertEqual(save('foo', '"'), '{"foo": "\\""}')
print('{"rc":"1"}') exit(1) def isfloat(value): """Check if value is float.""" try: float(value) return True except ValueError: return False with utils.gzopen(args.input) as f: # Split lines by tabs # Ignore lines without a number in second column # Build a dictionary of gene-expression pairs exp = { "genes": { gene_exp[0]: float(gene_exp[1]) for gene_exp in (l.split("\t") for l in f) if len(gene_exp) == 2 and isfloat(gene_exp[1]) } } if args.output: with open(args.output, "w") as f: json.dump(exp, f) else: send_message(save("exp_json", json.dumps(exp, separators=(",", ":"))))