in reply to Re: Use of Uninitialized in Concatenation or String Error?
in thread Use of Uninitialized in Concatenation or String Error?
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,
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 withchrX 1 1000000 chrX 1000001 2000001 chrX 2000001 3000001 ...etc.
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.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];
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++; } } }
|
|---|