Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3227422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:34:22+00:00 2026-05-17T16:34:22+00:00

I need to create a Bed module with these functions: readBed(file) – read a

  • 0

I need to create a Bed module with these functions:

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



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

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:

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

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:

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() < self.getEnd() and r.getEnd() >= self.getEnd()) or \
       (self.getStart() < r.getEnd() and self.getEnd() >= r.getEnd()) or \
       (self.getStart() >= r.getStart() and self.getEnd() <= r.getEnd()) or \
       (r.getStart() >= self.getStart() and r.getEnd() <= self.getEnd()):
      return True
    else:
      return False
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:34:23+00:00Added an answer on May 17, 2026 at 4:34 pm

    Without knowing the format in which the data is saved to file, I can only assume that it is being pickled. With that assumption in mind, I can give you the following code:

    import cPickle
    
    def readBed(filepath):
        with open(filepath, 'r') as f:
            data = cPickle.load(f)
            return data
    
    def writeBed(models, filepath):
        with open(filepath, 'w') as f:
            cPickle.dump(models, f)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.