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

  • SEARCH
  • Home
  • 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 8055105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:17:39+00:00 2026-06-05T08:17:39+00:00

I am trying to make some .bed files for genetic analysis. I am a

  • 0

I am trying to make some .bed files for genetic analysis. I am a python beginner. The files I want to make should be 3 columns, tab seperated, first column always the same (chromosome number) and 2nd and 3rd columns windows of size 200 starting at zero and ending at end of chromosome. Eg:

chr20 0 200
chr20 200 400
chr20 400 600
chr20 600 800
...

I have the size of the chromosome so at the moment I am trying to say ‘while column 2 < (size of chrom) print line. I have a skeleton of a script but it is not quite working, due to my lack of experience. Here is what I have so far:

output = open('/homw/genotyping/wholegenome/Chr20.bed', 'rw') 

column2 = 0
column1 = 0
while column2 < 55268282:
    for line in output:
        column1 = column1 + 0
        column2 = column2 + 100

        print output >> "chr20" + '\t' + str(column1) + '\t' + str(column2)

If anyone can fix this simple script so that it does as I described, or writes a better solution that would be really appreciated. I considered making a script that could output all files for 20 chromosomes and chrX but as I need to specify the size of the chromosome I think I’ll have to do each file separately.

Thanks in advance!

  • 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-06-05T08:17:40+00:00Added an answer on June 5, 2026 at 8:17 am

    How about this:

    step = 200 # change values by this amount
    with open('Chr20.bed', 'w') as outfp:
       for val in range(0, 1000, step):  #increment by step, max value 1000
          outfp.write('{0}\t{1:d}\t{2:d}\n'.format('chr20', val, val+step))
    

    gives tab delimited output as requested

    chr20   0   200
    chr20   200 400
    chr20   400 600
    chr20   600 800
    chr20   800 1000
    

    Note: using with will automatically close the file for you when you are done, or an exception is encountered.

    This gives more information about the .format() function in case you are curious.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make some project in which i want a text box
I'm trying to make some web-based board games, and I want the interface to
Im trying to make some queries, first, I do this one (and works): SELECT
I am trying to make some python scripts on google appspot. I am just
I am trying to make some changes to an opensource project. I want to
I am trying to make some kind of animation and I want it to
I learning python and django and trying to make some sort of simple forum.
I am trying to make some edits to a site for a client of
I'm trying to make some input fields that I would like to work like
I'm trying to make some common scopes for models to be sharing, so i

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.