Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generating limited amount of random numbers in Perl for a known range

    Hi!
    I am a newbie in here and wanted to ask a question that I am not able to find its answer. I have a file which has couple letters as :
    letters.txt :
    @string1 10 letters
    A H K Y M H O L H L
    @string2 9 letters
    H N U P W X L Y H
    I am trying to create a file which will only have random numbers from 20 to 60 for each letter, for each string.
    My expected output should look like :
    output.txt:
    @string1
    29 27 56 43 39 40 36 48 59 38
    @sting2
    26 36 39 39 26 51 38 42 42

    I have tried this code below:
    open ($fh, '>', $fileToLocate) or die;
    my $x = $minimum + int(rand($maximum - $minimum);
    print $fh "$x\n";
    close $fh;

    And it creates only 1 random number in my $fh file, however I want to extract the number of letters in each string (written just before "letter" in identifier) and create a loop which will give the expected output. I have tried to this below to create 30 random numbers ranging between 20 and 60, however it did not work out :
    my $x = join("", $minimum + int(rand($maximum - $minimum), ( 1 .. 30 ) );
    my @Chars = ( 20 .. 60);


    I am sorry if it is too much to ask, but I would very much appreciate if you show me a way to do it.

    Thank you so much in advance..

Latest Articles

Collapse

  • seqadmin
    Genetic Variation in Immunogenetics and Antibody Diversity
    by seqadmin



    The field of immunogenetics explores how genetic variations influence immune responses and susceptibility to disease. In a recent SEQanswers webinar, Oscar Rodriguez, Ph.D., Postdoctoral Researcher at the University of Louisville, and Ruben Martínez Barricarte, Ph.D., Assistant Professor of Medicine at Vanderbilt University, shared recent advancements in immunogenetics. This article discusses their research on genetic variation in antibody loci, antibody production processes,...
    11-06-2024, 07:24 PM
  • seqadmin
    Choosing Between NGS and qPCR
    by seqadmin



    Next-generation sequencing (NGS) and quantitative polymerase chain reaction (qPCR) are essential techniques for investigating the genome, transcriptome, and epigenome. In many cases, choosing the appropriate technique is straightforward, but in others, it can be more challenging to determine the most effective option. A simple distinction is that smaller, more focused projects are typically better suited for qPCR, while larger, more complex datasets benefit from NGS. However,...
    10-18-2024, 07:11 AM

ad_right_rmr

Collapse

News

Collapse

Topics Statistics Last Post
Started by seqadmin, Today, 11:09 AM
0 responses
22 views
0 likes
Last Post seqadmin  
Started by seqadmin, Today, 06:13 AM
0 responses
20 views
0 likes
Last Post seqadmin  
Started by seqadmin, 11-01-2024, 06:09 AM
0 responses
30 views
0 likes
Last Post seqadmin  
Started by seqadmin, 10-30-2024, 05:31 AM
0 responses
21 views
0 likes
Last Post seqadmin  
Working...
X