# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public # License (GPL) version 3, as described at www.opensource.org. # Copyright (C)2016 William H. Majoros ([email protected]). #========================================================================= from __future__ import (absolute_import, division, print_function, unicode_literals, generators, nested_scopes, with_statement) from builtins import (bytes, dict, int, list, object, range, str, ascii, chr, hex, input, next, oct, open, pow, round, super, filter, map, zip) from Fastb import Fastb import copy BASE="/Users/bmajoros/python/test/data" #filename=BASE+"/iter0_peak1858.standardized_across_all_timepoints.t05.fastb" filename=BASE+"/test.fastb" fastb=Fastb(filename) fastb.renameTrack("EP300","p300") p300=fastb.getTrackByName("p300") p300_2=copy.deepcopy(p300) p300_2.id="newtrack" fastb.addTrack(p300_2) fastb.dropTrack("DNase") numTracks=fastb.numTracks() print(numTracks,"tracks") for i in range(numTracks): track=fastb.getIthTrack(i) print(track.getID(),track.getLength()) fastb=fastb.slice(500,1500) fastb.save(BASE+"/test-out.fastb")
#!/usr/bin/env python #========================================================================= # This is OPEN SOURCE SOFTWARE governed by the Gnu General Public # License (GPL) version 3, as described at www.opensource.org. # Copyright (C)2016 William H. Majoros ([email protected]). #========================================================================= from __future__ import (absolute_import, division, print_function, unicode_literals, generators, nested_scopes, with_statement) from builtins import (bytes, dict, int, list, object, range, str, ascii, chr, hex, input, next, oct, open, pow, round, super, filter, map, zip) from Fastb import Fastb import ProgramName import sys if (len(sys.argv) != 2): sys.exit(ProgramName.get() + " in.fastb") filename = sys.argv[1] fastb = Fastb(filename) numTracks = fastb.numTracks() for i in range(numTracks): track = fastb.getIthTrack(i) L = track.getLength() id = track.getID() print(id + "\t" + str(L))
# Copyright (C)2016 William H. Majoros ([email protected]). #========================================================================= from __future__ import (absolute_import, division, print_function, unicode_literals, generators, nested_scopes, with_statement) from builtins import (bytes, dict, int, list, object, range, str, ascii, chr, hex, input, next, oct, open, pow, round, super, filter, map, zip) # The above imports should allow this program to run in both Python 2 and # Python 3. You might need to update your version of module "future". import sys from Fastb import Fastb if(len(sys.argv)!=4): exit(sys.argv[0]+" <from.fastb> <minus.fastb> <out.fastb>") (fromFile,minusFile,outFile)=sys.argv[1:] fromFastb=Fastb(fromFile) minusFastb=Fastb(minusFile) n=fromFastb.numTracks() for i in range(n): fromTrack=fromFastb.getIthTrack(i) id=fromTrack.getID() minusTrack=minusFastb.getTrackByName(id) fromData=fromTrack.getData() minusData=minusTrack.getData() L=len(fromData) if(len(minusData)!=L): exit("track lengths differ") for j in range (L): fromData[j]-=minusData[j] fromFastb.save(outFile)
#!/usr/bin/env python #========================================================================= # This is OPEN SOURCE SOFTWARE governed by the Gnu General Public # License (GPL) version 3, as described at www.opensource.org. # Copyright (C)2016 William H. Majoros ([email protected]). #========================================================================= from __future__ import (absolute_import, division, print_function, unicode_literals, generators, nested_scopes, with_statement) from builtins import (bytes, dict, int, list, object, range, str, ascii, chr, hex, input, next, oct, open, pow, round, super, filter, map, zip) from Fastb import Fastb import ProgramName import sys if(len(sys.argv)!=2): sys.exit(ProgramName.get()+" in.fastb") filename=sys.argv[1] fastb=Fastb(filename) numTracks=fastb.numTracks() for i in range(numTracks): track=fastb.getIthTrack(i) L=track.getLength() id=track.getID() print(id+"\t"+str(L))
# Copyright (C)2016 William H. Majoros ([email protected]). #========================================================================= from __future__ import (absolute_import, division, print_function, unicode_literals, generators, nested_scopes, with_statement) from builtins import (bytes, dict, int, list, object, range, str, ascii, chr, hex, input, next, oct, open, pow, round, super, filter, map, zip) from Fastb import Fastb import copy BASE = "/Users/bmajoros/python/test/data" #filename=BASE+"/iter0_peak1858.standardized_across_all_timepoints.t05.fastb" filename = BASE + "/test.fastb" fastb = Fastb(filename) fastb.renameTrack("EP300", "p300") p300 = fastb.getTrackByName("p300") p300_2 = copy.deepcopy(p300) p300_2.id = "newtrack" fastb.addTrack(p300_2) fastb.dropTrack("DNase") numTracks = fastb.numTracks() print(numTracks, "tracks") for i in range(numTracks): track = fastb.getIthTrack(i) print(track.getID(), track.getLength()) fastb = fastb.slice(500, 1500) fastb.save(BASE + "/test-out.fastb")