Thank you for the consideration, I truly appreciate it! My data spans 155,000,000 nucleotides. In my original code I opened the file: INTERVALS which stores the windows of varying sizes I'd like to use for sorting,

chrX 1 1000000 chrX 1000001 2000001 chrX 2000001 3000001 ...etc.
the largest being 1Mb (1,000,000) and assigned it to a scalar variable $interval. I chomp this scalar, assign an array to the split function of that $interval scalar and establish $start and $end variables by assigning them to the 1 and 2 array slices respectively. I don't wish to hard code my range because I have multiple windows to work with
open (INTERVAL, "/Users/logancurtis-whitchurch/Dropbox/thesis_folder/g +alaxy_chrX_data/chrX_1Mbwindow_nonoverlapping.interval") or die "can' +t open file\n"; while (my $interval = <INTERVAL>){ chomp($interval); my @find_interval = split(/\t/, $interval); my $start = $find_interval[1]; my $end = $find_interval[2];
from here i used an arbitrary switch variable to control when printing to a given output file should stop and a new file should begin to be printed to.

My condition, while $switch == 1 I open my data input file, specify and open my output file

my $switch = 1; while ($switch == 1) { open (CG, "/Users/logancurtis-whitchurch/Dropbox/thesis_folder +/CompleteGenomics/28_males_inAll/CGS.inall.28.chr.23.txt") or die "ca +n't open CG file\n"; my $output_file = "/Users/logancurtis-whitchurch/Desktop/temp_ +$count.txt"; open(OUT, ">$output_file");

Then with these 3 lines I create an array for the whole input file (@SNPs), make an array from each line or string in the input file (@get_SNP) and create a variable accounting for position ($position) that increments as the data is read via my placeholder variable ($placeholder)

my @SNPs = <CG>; my @get_SNP = split(/\t/, $SNPs[$placeholder]); my $position = $get_SNP[3];

I then use an if statement to say if my position in lt or eq to the end and greater than the start, print the $SNP[$placeholder] string corresponding to one data line, then increment $placeholder value, repeating the loop until the if statement is false. Then state else set $switch = 0 ending the while loop. Once this is done I increment a global variable $count that tells the open function to create a new output file since i interpolated the variable $count into the output file name earlier

my $switch = 1; while ($switch == 1) { if (($position < $end) && ($position >= $start)) { print OUT "$SNPs[$placeholder]\n"; $placeholder++; } else { $switch = 0; $count++; } } }

In reply to Re^2: Use of Uninitialized in Concatenation or String Error? by ccelt09
in thread Use of Uninitialized in Concatenation or String Error? by ccelt09

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.