Hello All,
I am very new to perl, and I have two files tab separated:
File1:
rs492602 **CC** Vitamin B12 deficiency FUT2 Higher lev
+els of vitamin B12
rs492602 CT Vitamin B12 deficiency FUT2 Normal lev
+els of vitamin B12
rs492602 TT Vitamin B12 deficiency FUT2 Normal le
+vels of vitamin B12
File2:
rs492602 **GG** exm-rs492602
rs492602 **CC** exm-rs492602
Result:
rs492602**CC** **GG** Vitamin B12 deficiency FUT2 Higher levels
+of vitamin B12
rs492602**CC** **CC** Vitamin B12 deficiency FUT2 Higher lev
+els of vitamin B12
So far I have tried this which matches only the RS_ids and not the basepairs:
use warnings;
use strict;
open(F1,$ARGV[0]) or die("could not open $ARGV[0] due to $!\n");
open(F2,$ARGV[1]) or die("could not open $ARGV[1] due to $!\n");
my @arr1=<F1>;
my @arr2=<F2>;
chomp(@arr1);
chomp(@arr2);
my $x=shift(@arr1);
my $i=0;
print "$x\n";
foreach my $line1(@arr2){
chomp($line1);
foreach my $line2(@arr1){
chomp($line2);
$line2=~/(\w+)\t.*/;
my $rsid=$1;
#while($rsid){
# $i++;
#}
if($line1 eq $rsid){
print "$line2\n";
$i++;
}
}
}
Thank you!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.