diff --git a/scripts/flatten_json.py b/scripts/flatten_json.py index 3679011..a395ef2 100644 --- a/scripts/flatten_json.py +++ b/scripts/flatten_json.py @@ -1,30 +1,32 @@ -import sys +#!/usr/bin/env python + import json +import sys from collections import OrderedDict -### -### gene1_name gene1_id, gene2_name, gene2_id, type, pair, split, txlist def loadJSON(fn): with open(fn) as f: - JJ = json.load(f,object_pairs_hook=OrderedDict) + JJ = json.load(f, object_pairs_hook=OrderedDict) return JJ['genes'] -def outputGeneTable(fusions, outf, filters = None): + +def outputGeneTable(fusions, outf, filters=None): outf.write('\t'.join("geneA.name geneA.id geneB.name geneB.id paircount splitcount transcripts.list".split())) outf.write('\n') for gf in fusions: gAname = gf['geneA']['name'] - gAid = gf['geneA']['id'] + gAid = gf['geneA']['id'] gBname = gf['geneB']['name'] - gBid = gf['geneB']['id'] - pairs = str(gf['paircount']) - split = str(gf['splitcount']) + gBid = gf['geneB']['id'] + pairs = str(gf['paircount']) + split = str(gf['splitcount']) txp = [tp['fasta_record'] for tp in gf['transcripts']] outf.write('\t'.join([gAname, gAid, gBname, gBid, pairs, split, ';'.join(txp)])) outf.write('\n') + def usage(): print("Usage: python flatten_json.py fusion.out.json [genetable.txt]") print("") @@ -41,9 +43,9 @@ def usage(): fusions = loadJSON(infn) outf = sys.stdout if nargs == 3: - outf = open(sys.argv[2],'w') + outf = open(sys.argv[2], 'w') - outputGeneTable(fusions,outf) + outputGeneTable(fusions, outf) if outf != sys.stdout: outf.close() diff --git a/scripts/get_fragment_length.py b/scripts/get_fragment_length.py index 5b48543..01d0b58 100644 --- a/scripts/get_fragment_length.py +++ b/scripts/get_fragment_length.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import h5py import numpy as np import sys @@ -20,7 +22,7 @@ def get_cumulative_dist(fn): print(" cutoff: percentage cutoff to use (default .95)") else: fn = sys.argv[1] - if len(sys.argv) >=3: + if len(sys.argv) >= 3: cutoff = float(sys.argv[2]) if cutoff <= 0 or cutoff >= 1.0: cutoff = 0.95