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 7815695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:36:07+00:00 2026-06-02T05:36:07+00:00

I need to create a program called extractGenes.py The command line parameters need to

  • 0

I need to create a program called extractGenes.py

The command line parameters need to take 2 OR 3 parameters:

  1. -s is an optional parameter, or switch, indicating that the user wwants the spliced gene sequence(introns removed). The user does not have to provide this (meaning he wants the entire gene sequence), but it he does provide it then it must be the first parameter

  2. input file (with the genes)

  3. output file (where the program will create to store the fasta file

The file contains lines like this:

NM_001003443 chr11 + 5925152 592608098 2 5925152,5925652, 5925404,5926898,

However, I am not sure how to include the -s optional parameter into the starting function.

So I started with:

getGenes(-s, input, output):
fp = open(input, 'r')
wp = open(output, "w")

but am unsure as to how to include the -s.

  • 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-02T05:36:08+00:00Added an answer on June 2, 2026 at 5:36 am

    This case is simple enough to use sys.argv directly:

    import sys
    
    spliced = False
    if '-s' in sys.argv:
        spliced = True
        sys.argv.remove('-s')
    infile, outfile = sys.argv[1:]
    

    Alternatively, you can also use the more powerful tools like argparse and optparse to generate a command-line parser:

    import argparse
    
    parser = argparse.ArgumentParser(description='Tool for extracting genes')
    parser.add_argument('infile', help='source file with the genes')
    parser.add_argument('outfile', help='outfile file in a FASTA format')
    parser.add_argument('-s', '--spliced', action='store_true', help='remove introns')
    
    if __name__ == '__main__':
        result = parser.parse_args('-s myin myout'.split())
        print vars(result)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a C++ dll that will be called from another program
I need to create program that creates a XML schema like below using System.Xml.XmlSchema
I need to create an installer program that will do install the following: ASP.Net
I want to create a program that produces an executable slideshow. So I need
We need to create a program in PHP/MySQL that will display all the 'people',
For a school project I need to create a program and it'd be nice
I need to create several Raphael objects in my program. field1 and field2 are
I need my program to create and edit a config file, which would contain
My current program need to use programatically create a XPathExpression instance to apply to
I was trying to create a lzw compression program. But i need to finish

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.