Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi, I wrote a script to compare values on two columns, but I only want to do this while the id on the 4th column remains the same. The file looks like this:
chr1 15865 15915 cg13869341 908 913 chr1 18827 18877 cg14008030 688 776 chr1 29407 29457 cg12045430 43 70 chr1 29407 29457 cg12045430 43 88 chr1 29407 29457 cg12045430 43 16 chr1 29425 29475 cg20826792 57 70 chr1 29425 29475 cg20826792 57 88 chr1 29425 29475 cg20826792 57 16 chr1 29435 29485 cg00381604 33 70 chr1 29435 29485 cg00381604 33 88 chr1 29435 29485 cg00381604 33 16 chr1 68849 68899 cg20253340 560 593 chr1 69591 69641 cg21870274 791 809 chr1 91550 91600 cg03130891 55 84
So for example I want to compare line 3,4,5 because they have the same id in column 4. My code looks like this now:
open(intersectMethyl,'<',"intersect148methyl.bed") or die $!; my @methylData = <intersectMethyl>; close(intersectMethyl); my @methylScore; my @ids; for my $line(@methylData){ my($chr,$start,$end,$id,$scoreNormal,$scoreTumor) = split("\t",$li +ne); push(@ids, $id); for ($i = 1; $i<eof; $i++){ if (@ids[$i]==@ids[$i-1] && (($scoreTumor/1000) - ($scoreNormal +/1000) >= 0.2)){ push(@methylscore, "$chr $start $end $id $scoreNor +mal $scoreTumor") } } } open(RESULTS,'>','methylDifferences.txt') or die $!; foreach(@methylscore){ print RESULTS "$_\n"; } close(RESULTS);
But this doesn't work.. Could somebody help me? Thanks!

In reply to compare values while value on other column remains the same by linseyr

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 admiring the Monastery: (7)
As of 2024-04-18 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found