Python Bed module
<p>I need to create a Bed module with these functions: </p>

<p>readBed(file) – read  a  BED  format  file  and  constructs  a  list  of  gene  model  objects  from  the  data  it  contains.  </p>

<p>writeBed(models=models,fname=file)  –  writes  the  given  list  of  gene  model  objects  and   writes  them  to  a  file  named  fname.</p>

<p>For the readBed, I was thinking about readline function that I have wrote before, and add the codes for it to return a result as a list. For writeBed, I really am clueless. Here is my codes, please guide me everyone:</p>

<pre><code>def ReadBed(file):
  result = []
  line = fh.readline()
  if not line:
      fh.close()
  else:
      return result

def writeBed(models=models, fname=file):
  if file.ReadBed = result
  return result in fname
</code></pre>

<p>Also, I had a Range class like this, and I want to raise TypeError and ValueError for my class, but not sure how to do it, can everyone please help me too. Thank you so much everyone:</p>

<pre><code>class Range:
  def __init__(self, start, end):
    self.setStart(start)
    self.setEnd(end)
  def getStart(self):
    return self.start
  def setStart(self, s):
    self.start = s
  def getEnd(self):
    return self.end
  def setEnd(self, e):
    self.end = e
  def getLength(self):
    return len(range(self.start, self.end))
  def overlaps(self, r):
    if (r.getStart() &lt; self.getEnd() and r.getEnd() &gt;= self.getEnd()) or \
       (self.getStart() &lt; r.getEnd() and self.getEnd() &gt;= r.getEnd()) or \
       (self.getStart() &gt;= r.getStart() and self.getEnd() &lt;= r.getEnd()) or \
       (r.getStart() &gt;= self.getStart() and r.getEnd() &lt;= self.getEnd()):
      return True
    else:
      return False
</code></pre>
