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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:28:23+00:00 2026-05-11T17:28:23+00:00

For example, The function could be something like def RandABCD(n, .25, .34, .25, .25):

  • 0

For example,
The function could be something like def RandABCD(n, .25, .34, .25, .25):

Where n is the length of the string to be generated and the following numbers are the desired probabilities of A, B, C, D.

I would imagine this is quite simple, however i am having trouble creating a working program. Any help would be greatly appreciated.

  • 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-11T17:28:24+00:00Added an answer on May 11, 2026 at 5:28 pm

    Thank you all for your help, I was able to figure something out, mostly with this info.
    For my particular need, I did something like this:

    import random
    #Create a function to randomize a given string
    def makerandom(seq):
        return ''.join(random.sample(seq, len(seq)))
    def randomDNA(n, probA=0.25, probC=0.25, probG=0.25, probT=0.25):
        notrandom=''
        A=int(n*probA)
        C=int(n*probC)
        T=int(n*probT)
        G=int(n*probG)
    
    #The remainder part here is used to make sure all n are used, as one cannot
    #have half an A for example.
        remainder=''
        for i in range(0, n-(A+G+C+T)):
            ramainder+=random.choice("ATGC")
        notrandom=notrandom+ 'A'*A+ 'C'*C+ 'G'*G+ 'T'*T + remainder
        return makerandom(notrandom)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you store dates as Unix timestamps in the database,… May 12, 2026 at 12:44 am
  • Editorial Team
    Editorial Team added an answer You can use the addFilterQuery() method on the SolrQuery class.… May 12, 2026 at 12:44 am
  • Editorial Team
    Editorial Team added an answer Just keep a table for the "many", with a key… May 12, 2026 at 12:44 am

Related Questions

I am writing a web-framework for Python, of which the goal is to be
referring to this question , I've decided to duplicate the tables every year, creating
Have you ever been frustrated by Visual Studio not re-evaluating certain watch expressions when
I am to build a PHP application for a website that already has another

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.