473,395 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Table matching and concatenation

Hi All,
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
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. my ($start,$end,$sequence,$se,@se,$id,$acc,$seq);
  6. my $cnt=0;
  7. my %hash;
  8. open(FH,"test1");
  9. while(<FH>)
  10. {
  11.     my @temp = split(/\t/,$_);
  12.         $id    = $temp[0];
  13.         $acc   = $temp[1];
  14.         $start = $temp[2];
  15.         $end   = $temp[3];
  16.         $hash{$acc} = $id;
  17.     #print "$temp[1]\t$temp[2]\t$temp[3]\n";
  18. }
  19. while ( ($acc,$id) = each %hash ) {
  20.     #print "$acc => $id\n";
  21. }
  22. close(FH);
  23.  
  24. open(TH,"test2");
  25. while(<TH>)
  26. {
  27.     chomp $_;
  28.     my @temp1=split(/\t/,$_);
  29.  
  30.     if(exists $hash{$temp1[0]})
  31.     {
  32.         #print "$hash{$temp1[0]}\n";
  33.         @se=split("",$temp1[2]);
  34.         do{
  35.             if($start eq @se)
  36.             {
  37.                 $seq .=$temp1[2];
  38.             }
  39.         } while($end eq @se);
  40.     print "$seq\n";
  41.     }
  42.  
  43.  
  44.     #print "$se[0]\n";
  45.     #$cnt++;
  46.  
  47.     #print "$temp1[2]\n";
  48. }
  49. #print $cnt;
  50. close(TH);
  51.  
  52.  
thanks for any help.
Kumar
Nov 19 '07 #1
2 1086
numberwhun
3,509 Expert Mod 2GB
Well, to start with, can you post the "uninitialized errors"? We will want you to have those worked out first.

Regards,

Jeff
Nov 21 '07 #2
KevinADC
4,059 Expert 2GB
even if he gets that worked out, this is not correct usage/syntax, although I am unsure what the OP is trying to do with this condition:

Expand|Select|Wrap|Line Numbers
  1. while($end eq @se);

and there is is no hash here:

Expand|Select|Wrap|Line Numbers
  1. while ( ($acc,$id) = each %hash ) {
  2.     #print "$acc => $id\n";
  3. }
but I guess that loop isn't doing anything ayway. Probably more basic problems in the code.

Seing a sample of the data would also be nice.
Nov 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
17
by: Andrew McLean | last post by:
I have a problem that is suspect isn't unusual and I'm looking to see if there is any code available to help. I've Googled without success. Basically, I have two databases containing lists of...
12
by: TP | last post by:
Hi, I have been given the name of a table. IT has all kinds of information that is relevant to the user. The problem is that the user does not exactly know which column this value he is...
1
by: geronimo_me | last post by:
Hi, I have a small problem I am trying to check if field1 in Table1 matches Field2, Field3 or Field4 in Table2: ie Record 1 Table1 Field1 = ABC Table2
10
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't...
1
by: Little | last post by:
Could someone start me on putting in a table into this code, and some HTML tags. I would to make the table below the map and have a header at the top. Thanks for the help. """ Publisher example...
34
by: Larry Hastings | last post by:
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. ...
3
ebs57
by: ebs57 | last post by:
I am looking for some basic help in understanding and setting up table relationships in Access. I've created one table called PROJECTS and it has the field JobNo which I've declared as the key...
5
by: Stephen | last post by:
Hello, I have 2 tables, one contains log of all incoming phone calls, and the other one is simply a phone book. I want to fetch caller's name if it's already exist in the phone book, and if it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.