Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

ig effectively addressed your split issue.

I have a question about pushing 1552 randomly-obtained strings from @X_info onto @tmp, and then doing a splice to move the first 26 from @tmp into @PAR1. (Although jethro correctly pointed out that @tmp is never reset, so strings keep getting pushed onto it. Nevertheless, the randomness doesn't essentially change.) Why not just generate those first 26 randomly-obtained strings, one at a time, and split them as you go? In both cases--1552 using the first 26 vs. just generating 26--the 26 strings were randomly obtained from a superset. Is there a certain protocol that you're following that requires you to generate all 1552 and then grab the first 26 for processing? If not, then consider the following refactoring:

use warnings; use strict; my $runs = 1; # for testing code # Program vars my $chr_X_input = "bootstrap_data.txt"; my $range = 1552; # total number of array elem +ents my $pi_sum; my $L_sum; my $differences_sum; my $coverage_sum; open my $CHR_X_INPUT, '<', $chr_X_input or die "Can't open chromosome +X input: $!"; chomp( my @X_info = <$CHR_X_INPUT> ); close $CHR_X_INPUT; for ( 1 .. $runs ) { for ( 1 .. 26 ) { my ( $pi, $L, $differences, $coverage ) = split /\t/, $X_info[ + int( rand($range) ) ]; $pi_sum += $pi; $L_sum += $L; $differences_sum += $differences; $coverage_sum += $coverage; my $PAR1_diversity = ( ( $pi_sum / $L_sum ) / ( $differences_s +um / $coverage_sum ) ); } }

Hope this helps!


In reply to Re: Assigning Variables to String Elements by Kenosis
in thread Assigning Variables to String Elements by ccelt09

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-25 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found