Loads a track from disk, whatever the format is.
Parameters: |
|
---|---|
Returns: | a Track instance |
import track
with track.load('tracks/rp_genes.bed') as rpgenes:
data = rpgenes.read()
with track.load('/tmp/ae456f0', 'sql') as t:
data = t.read()
with track.load('tracks/repeats.bed', readonly=True) as repeats:
data = repeats.read()
with track.load('http://example.com/genes.bed') as genes:
data = genes.read()
Creates a new empty track in preparation for writing to it.
Parameters: | |
---|---|
Returns: | a Track instance |
import track
with track.new('tmp/track.sql') as t:
t.write('chr1', [(10, 20, 'Gene A', 0.0, 1)])
t.set_chrmeta('hg19')
with track.new('tracks/peaks.sql', 'sql') as t:
t.fields = ['start', 'end', 'name', 'score']
t.write('chr5', [(500, 1200, 'Peak1', 11.3)])
Converts a track from one format to an other. The source file should have a different format from the destination file. If either the source or destination are missing a file extension, you can specify their formats using a tuple. See examples below.
Parameters: |
|
---|---|
Returns: | the path to the track created (or a list of track paths in the case of multi-track files). |
import track
track.convert('tracks/genes.bed', 'tracks/genes.sql')
track.convert('tracks/genes.sql', 'tracks/genes.bigWig', assembly='hg19')
track.convert(('tracks/no_extension', 'gff'), 'tracks/genes.sql')
track.convert(('tmp/4afb0edf', 'bed'), ('tmp/converted', 'wig'))