Commit 1d75c63b authored by Mikael Boden's avatar Mikael Boden

minor

parent 3ff492de
...@@ -661,11 +661,13 @@ class BedFile(): ...@@ -661,11 +661,13 @@ class BedFile():
newrows.append(entry) newrows.append(entry)
return BedFile(newrows, format = self.format) return BedFile(newrows, format = self.format)
def write(self, filename, format = 'BED6'): def write(self, filename, format = 'BED6', header = None):
""" Save the data """ Save the data
format - the format to use for WRITING, currently only BED6 ('Optional' 6-col format) is supported. format - the format to use for WRITING, currently only BED6 ('Optional' 6-col format) is supported.
""" """
f = open(filename, 'w') f = open(filename, 'w')
if header:
f.write(header + '\n')
for row in self.__iter__(): for row in self.__iter__():
if self.format == 'Peaks': if self.format == 'Peaks':
#f.write("%s %d %d %s %d %s %f %f" % (row.chrom, row.chromStart, row.chromEnd, row.name, row.score, row.strand, row.signalValue, row.pValue)) # seems to cause issues in UCSD Genome Browser #f.write("%s %d %d %s %d %s %f %f" % (row.chrom, row.chromStart, row.chromEnd, row.name, row.score, row.strand, row.signalValue, row.pValue)) # seems to cause issues in UCSD Genome Browser
...@@ -713,11 +715,13 @@ def readBedFile(filename, format = 'Limited'): ...@@ -713,11 +715,13 @@ def readBedFile(filename, format = 'Limited'):
""" """
return BedFile(filename, format) return BedFile(filename, format)
def writeBedFile(entries, filename, format = 'BED6'): def writeBedFile(entries, filename, format = 'BED6', header = None):
""" Save the BED entries to a BED file. """ Save the BED entries to a BED file.
format - the format to use for WRITING, currently only BED6 ('Optional' 6-col format) is supported. format - the format to use for WRITING, currently only BED6 ('Optional' 6-col format) is supported.
""" """
f = open(filename, 'w') f = open(filename, 'w')
if header:
f.write(header + '\n')
for row in entries: for row in entries:
if format == 'Peaks': if format == 'Peaks':
#f.write("%s %d %d %s %d %s %f %f" % (row.chrom, row.chromStart, row.chromEnd, row.name, row.score, row.strand, row.signalValue, row.pValue)) # seems to cause issues in UCSD Genome Browser #f.write("%s %d %d %s %d %s %f %f" % (row.chrom, row.chromStart, row.chromEnd, row.name, row.score, row.strand, row.signalValue, row.pValue)) # seems to cause issues in UCSD Genome Browser
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment