spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

find values in a range of 2 values


I think you're tackling this backwards. Parsing table2 first into a hash makes the problem a lot easier. Because then you can iterate table1 and check for any values in the range in question.

use strict;
use warnings;
use Data::Dumper;

my %table2;

while (<DATA>) {
    #stop reading if we've finished with table2
    last if m/^table1/;

    next unless m/^rs/;
    my ( $col1, $col2 ) = split(/s+/);
    $table2{$col1} = $col2;
}

print Dumper \%table2;

while (<DATA>) {

    next unless m/^id/;
    chomp;
    my ( $rowid, $col2, $lower, $upper ) =
split(/s+/);
    my $newcol = "";
    foreach my $rs ( keys %table2 ) {
        if (    $table2{$rs} >= $lower
            and $table2{$rs} <= $upper )
        {
            $newcol .= " $rs:$table2{$rs}";
        }
    }
    print join( "	", $rowid, $col2, $lower,
$upper, $newcol, ), "
";
}


__DATA__
table2
col1    col2
rs1     5   
rs2     11
rs3     34
rs4     35

table1
col1    col2    col3    col4
id1     ...     1       10
id2     ...     15      20
id3     ...     30      35

output

$VAR1 = {
          'rs1' => '5',
          'rs2' => '11',
          'rs4' => '35',
          'rs3' => '34'
        };
id1 ... 1 10   rs1:5
id2 ... 15  20  
id3 ... 30  35   rs4:35 rs3:34

Categories : Perl

Related to : find values in a range of 2 values
how to use ggplot within range of values
I think this is what you're looking for: df$group <- cut(df$Freq, breaks = seq(0, max(df$Freq) + 4, by = 5), include.lowest = T) ggplot(df, aes(x = group)) + geom_bar()

Categories : R
Seekbar with range of two values (min and max)
Use range: true option! <!DOCTYPE html> <html> <head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"><

Categories : Javascript
converge values to range [-pi,pi] in matlab, NOT using wraptopi
To expand on @Ben Voight, you could use modulo-style operations this way: To wrap to [0, 2*pi], you'd do this: angle_rad = angle_rad - 2*pi*floor(angle_rad/(2*pi)); To wrap to [-pi, +pi], you'd add another term angle_rad = angle_rad - 2*pi*floor( (angle_rad+pi)/(2*pi) );

Categories : Matlab
Changing line style for certain range of values using matplotlib
In the following I have put together 4 different examples. They show different things: The simplest way to recreate the graph in your question. Note, that each line is only defined by two points. This is what I assume you have: two x and y vectors that define each line (in my example they each have 100 values). This one is most interesting for you (I guess): The vectors solid1 and solid2 are use

Categories : Python
Draw gridlines at the average (or median) values of a range in d3.js
You'll want to calculate the mean and median based on your data, instead of your scale: ymean = d3.mean(inputData, function(d) { return d.xVal; }); xmean = d3.mean(inputData, function(d) { return d.yVal; }); These are generic accessor functions, if you need specific guidance on the accessor function (the function(d) { return d.xVal; } part), you'll need to provide the format of your input dat

Categories : Javascript
Recently Add
unable to connect selenium webDriver through perl bindings
SSL error calling Perl web service via https using LWP
SOAP::Lite always faults in debug mode
perl referencing a hash outside of the scope that populated it (histogram)
Perl script to print out all the lines containing a keyword and the line below it
PERL Unicode Escape string pass from command line argument wrong output
Perl process crashes after handling signal
Marpa: Can I explicitly disallow keywords as identifiers?
Perl: Import text, containing ÅÄÖ, from file
error using perl - Proc::ProcessTable. works in cmd line, not in .pl file
DBIx::Class chaining resultsets with same table in prefetch
Time as input, print timetable in Perl
compare values of different tables perl
Automatically increasing ID generation using PERL
Syntax Error, first line after dostuff
Delete files in a folder using Perl
Perl '-d' operator is not detecting a directory
Perl appending text to new line
write_timeout in IO::Socket::Timeout
Using ForkManager and Perl properly?
Is a cyclic dependency solved with require?
Posting metric to google analytics from perl script
How can I check if a user enters my page the first time?
Sorting arrays of intervals in perl?
Perl: How to get the link target of a soundcloud feed mp3
Uninitialized value in concatenation
Perl code - pipe "|" in `open()` statement
perl command line backticks with matrix
Perl OO - Creating a list of objects
extract gene-id + function annotation from .gff
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.