I have 2 tables:
tab1: has 4 columns tab separated- id,ac,start,end.
tab2: has 3 columns tab separated- id, seq, desc.
what i am trying to do, when id of tab1 matches with id of tab2 then program should take start and end coordinates from tab1 and pool out seq from tab2 and trying to make a third table with id, ac, seq(with only start and end coordinate).
my code is given below but its giving me some uninitialized errors.
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl
- use strict;
- use warnings;
- my ($start,$end,$sequence,$se,@se,$id,$acc,$seq);
- my $cnt=0;
- my %hash;
- open(FH,"test1");
- while(<FH>)
- {
- my @temp = split(/\t/,$_);
- $id = $temp[0];
- $acc = $temp[1];
- $start = $temp[2];
- $end = $temp[3];
- $hash{$acc} = $id;
- #print "$temp[1]\t$temp[2]\t$temp[3]\n";
- }
- while ( ($acc,$id) = each %hash ) {
- #print "$acc => $id\n";
- }
- close(FH);
- open(TH,"test2");
- while(<TH>)
- {
- chomp $_;
- my @temp1=split(/\t/,$_);
- if(exists $hash{$temp1[0]})
- {
- #print "$hash{$temp1[0]}\n";
- @se=split("",$temp1[2]);
- do{
- if($start eq @se)
- {
- $seq .=$temp1[2];
- }
- } while($end eq @se);
- print "$seq\n";
- }
- #print "$se[0]\n";
- #$cnt++;
- #print "$temp1[2]\n";
- }
- #print $cnt;
- close(TH);
Kumar