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

minor

parent 3ff492de
......@@ -661,11 +661,13 @@ class BedFile():
newrows.append(entry)
return BedFile(newrows, format = self.format)
def write(self, filename, format = 'BED6'):
def write(self, filename, format = 'BED6', header = None):
""" Save the data
format - the format to use for WRITING, currently only BED6 ('Optional' 6-col format) is supported.
"""
f = open(filename, 'w')
if header:
f.write(header + '\n')
for row in self.__iter__():
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
......@@ -713,11 +715,13 @@ def readBedFile(filename, format = 'Limited'):
"""
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.
format - the format to use for WRITING, currently only BED6 ('Optional' 6-col format) is supported.
"""
f = open(filename, 'w')
if header:
f.write(header + '\n')
for row in entries:
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
......
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