LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2009, 06:16 AM   #1
deeptic
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Rep: Reputation: 0
creating perl dictionary


Dear all,
I have a sample file as follows;-

ID 1433B_HUMAN Reviewed; 246 AA.
AC P01892; O19619; P06338; P10313; P30444; P30445; P30446; P30514;
AC Q29680; Q29837; Q29899; Q95352; Q95380; Q9TPX8; Q9TPX9; Q9TPY0;
AC Q9TQH5; Q9TQI3;
DT 01-JUL-1993, integrated into UniProtKB/Swiss-Prot.
DT 23-JAN-2007, sequence version 3.
DT 28-JUL-2009, entry version 109.
DE RecName: Full=14-3-3 protein beta/alpha;
DE AltName: Full=Protein kinase C inhibitor protein 1;
DE Short=KCIP-1;
DE AltName: Full=Protein 1054;
DE Contains:
DE RecName: Full=14-3-3 protein beta/alpha, N-terminally processed;
GN Name=CXCL14; Synonyms=NJAC, SCYB14; ORFNames=UNQ240/PRO273;
OS Homo sapiens (Human).
OC Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi;
OC Mammalia; Eutheria; Euarchontoglires; Primates; Haplorrhini;
OC Catarrhini; Hominidae; Homo.
OX NCBI_TaxID=9606;
RN [1]
RP NUCLEOTIDE SEQUENCE [MRNA].
//

AC P62258; B3KY71; P29360; P42655; Q53XZ5; Q63631; Q7M4R4;
DT 05-JUL-2004, integrated into UniProtKB/Swiss-Prot.
DT 05-JUL-2004, sequence version 1.
DT 28-JUL-2009, entry version 68.
DE RecName: Full=14-3-3 protein epsilon;
DE Short=14-3-3E;
GN Name=YWHAE;
OS Homo sapiens (Human).
OC Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi;
OC Mammalia; Eutheria; Euarchontoglires; Primates; Haplorrhini;
OC Catarrhini; Hominidae; Homo.
OX NCBI_TaxID=9606;
RN [1]
RP NUCLEOTIDE SEQUENCE [MRNA].

I want to create a dictionary with keys and its values such that my keys are the first two digit in the entry. In the next step i want to print the values of the keys in the desired order.
for example in the second part of the data which says
AC P62258; B3KY71; P29360; P42655; Q53XZ5; Q63631; Q7M4R4;
if i want AC to be printed i need to search this key and print the elements of this key P62258; B3KY71; P29360; P42655; Q53XZ5; Q63631; Q7M4R4;
can someone help me to build this dictionary and print the keys in the way its required.

Thanks in advance.
 
Old 09-08-2009, 08:04 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Hi deeptic,

Sorry to sound rude but I think the general idea of these forums is to assist you when you get stuck, not to do your work for you. Please have a go first then ask for help if you run into trouble, people are usually more willing to help someone who has tried

cheers,

kbp
 
Old 09-08-2009, 10:53 AM   #3
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
In Perl, it's called a "hash" and you'll find excellent examples of all kinds in perldoc perldsc.

For the basics, I'll recommned to read perldoc perldata first.

Essentially, you do a my %hash and fill it in a loop for example with $hash{$yourkey} = $yourvalue and that's about it.
 
Old 09-09-2009, 02:22 AM   #4
deeptic
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for the suggestion. I shall go through the example script and syntax of hash and try.
 
Old 09-09-2009, 02:47 AM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
To OP: look up BioPerl - maybe there is a solution to your specific problem (not that you do not have to know basic things in Perl).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Suggest a good offline dictionary-database for gnome-dictionary. abhijeetnayak Linux - Software 1 07-05-2009 05:17 PM
Creating a Perl Program with options HyperTrey Programming 15 12-18-2008 08:29 PM
creating environment variables in perl iceman_san Linux - Newbie 7 08-11-2007 08:56 PM
Creating AT jobs with perl Elguapo Programming 3 07-23-2007 06:43 PM
creating userid's in perl BBQ_Matt Programming 1 01-28-2004 01:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration