|Keep It Simple, Stupid|
Reading values from one .csv, searching for closest values in second .csv, returning results in third .csv?by pickleswarlz (Initiate)
|on Feb 22, 2013 at 22:27 UTC||Need Help??|
pickleswarlz has asked for the
wisdom of the Perl Monks concerning the following question:
I am pretty new to Perl, but have what I think is a complex problem that is way beyond my abilities.
I have one .csv file that contains the locations of genes in the genome that looks like this:
where the first column indicates the chromosome number that the locations map to, second column is the start position of the gene in the genome, and the third column is the end position of the gene in the genome.
I have a second .csv file that gives a set of other locations in the genome with identification numbers:
where the first column is the identifier (alphanumeric), and the second column is the position in the genome.
What I would like to do is find the two locations from the second file that are closest to either side of location given in the first file, and output these to a new file. For example, for this line in .csv file 1:chr1 220 250
search CSV file 2 for the two closest values on either side of 220 AND the two closest values on either side of 250, given the following output .csv file:
I'm a Windows user, and relatively competent with the command line. I'll have to run this Perl script on multiple files, so I'd love to be able to specify the input and output files in the command line as I go rather than specifying them in the script itself. The files containing the ID information is huge, around 500,000 lines, so I'm wondering if it might be better to transform that file into a hash first.