def open_trackfactory(parser, options): tf = TrackFactory(options.file, "r+") if tf.has_track(options.name): tf.close() parser.error("trackfactory '%s' already has track named '%s'" % (options.file, options.name)) return tf
def view_track(parser, options): tf = TrackFactory(options.file, "r") if not tf.has_track(options.name): tf.close() parser.error("trackfactory '%s' does not contain track '%s'" % (options.file, options.name)) region = parse_interval(options.region) t = tf.get_track(options.name) track_type = t.get_type() logging.debug("opened track '%s' type '%s'" % (options.name, track_type)) if track_type == SequenceTrack.__name__: print t[region] if track_type == ArrayTrack.__name__: if options.file_type == "bedgraph": t.tobedgraph(region, sys.stdout) else: print t[region] elif track_type == VectorTrack.__name__: if options.file_type == "bedgraph": readnum = options.readnum allele = options.allele t.tobedgraph(region, sys.stdout, norm=True, read=readnum, allele=allele) else: print t[region] elif track_type == RnaseqTrack.__name__: cov_track = t.get_coverage_track() print cov_track.density(region) junc_track = t.get_junction_track() print junc_track[region] logging.debug("done") tf.close()
def remove_track(parser, options): tf = TrackFactory(options.file, "r+") if not tf.has_track(options.name): tf.close() parser.error("trackfactory '%s' does not contain track '%s'" % (options.file, options.name)) tf.delete_track(options.name) tf.close() logging.info("removed track '%s' from trackfactory '%s'" % (options.name, options.file))