I have got a file containing info abt node id and labels, which looks like this -
-645 _1__46__1__46__1__46__145__45__RXN
-
-435 _3__45__OXOACYL__45__ACP__45__REDUCT__45__RXN
-
-1084 RXN__45__4262
-
-565 RXN__45__4264
-
-740 RXN__45__710
-
-1290 RXN__45__7698
-
-1017 LIPOXYGENASE__45__RXN
-
-198 RXN__45__1321
-
-1151 RXN__45__4121
-
-55 GIBBERELLIN__45__3__45__BETA__45__DIOXYGENASE__45__RXN
-
-1276 NARINGENIN__45__3__45__DIOXYGENASE__45__RXN
-
-653 RXN__45__113
-
-455 RXN__45__114
-
i have to read this file into a hash, for which i converted it first into an array, and then to hash, using a program like this -
open (NODES, "node.txt") || die "File not found\n";
-
@nodearray=<NODES>;
-
%nodehash=@nodearray;
-
now i have got to take labels as input from the user, and return the node id. I have been trying the following code -
# usr/bin/perl -w
-
-
$start_node = 'AT1G51570';
-
$end_node = 'AT5G1110';
-
-
open (NODES, "node.txt") || die "File not found\n";
-
@nodearray=<NODES>;
-
%nodehash=@nodearray;
-
-
while (($node_id,$label) = each %nodehash) {
-
if ($nodehash{$label} = $start_node) {
-
print $nodehash{$node_id};
-
}
-
}
-
but nothing is working out. Please help me out on it. I am new to programming, and my deadline is just arriving. Please suggest something....
2 1727
Please suggest something...
ask a question that we can understand so we can attempt to answer it.
but nothing is working out. Please help me out on it. I am new to programming, and my deadline is just arriving. Please suggest something....
Just taking a quick look, I am going to guess that this is not the entire data file since the $start_node value doesn't exist anywhere in there.
I must say that I agree with Kevin and need to clarify better what exactly you are asking and looking for. You say that the two fields in the file are node_id and label, in that order. Then the user enters a label, you are supposed to match it against the file and if a match occours, then print the node_id. From what I can see though, that is NOT what you are doing. You are comparing what the user would enter to a fixed value($start_node), if the user were even able to enter a value. Your script doesn't allow for the user input that you are mentioning.
I think that you really need to clean up this program and try to get it working. Heck, pick up a copy of Learning Perl as it will truely help you with the language and writing Perl code. If you still have problems after trying to meet your requirements, then be sure to repost, but please word the question better so we are able to assist you.
Regards,
Jeff
Sign in to post your reply or Sign up for a free account.
Similar topics
by: _DS |
last post by:
I'm currently using a switch with about 50 case statements in a
stretch of code that's parsing XML attributes. Each case is a string.
I'm told that switch statements will actually use hash tables...
|
by: sp |
last post by:
i have an xml file (an rss file)
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<title>CodeGuru.com</title>
<link>http://www.codeguru.com/</link>
<description>The number one developer...
|
by: EP |
last post by:
This inquiry may either turn out to be about the suitability of the
SHA-1 (160 bit digest) for file identification, the sha function in
Python ... or about some error in my script. Any insight...
|
by: John Wright |
last post by:
I want to create a file hash on my exe files and store the hash signature in
a database so I can retrieve the value to compare the file hash to ensure I
have an untampered file. How can this be...
|
by: mens libertina |
last post by:
Disclaimer: In addition to reading the skimpy entries at php.net, I've
searched this group and alt.php to no avail.
Basically, I'm trying to use a template to send email reminders, but I
can't...
|
by: Iris83 |
last post by:
Hi,
Im a new to perl and i hope there are people here that can help me!
I have a realy large file like this.
1,12,T,
2,13,B,
3,14,T,
4,15,B,
I want to use the 2nd and 3th column and put it...
|
by: amittewarii |
last post by:
Hello Everybody ,
I need help in parsing the given file ,
#################################################################
<sample_cfg : 00FF_F000>
#f_name ...
|
by: subeen |
last post by:
Hi,
I am trying to parse a rss similar to the one found here (in example) http://www.feedforall.com/mediarss.htm
<!-- Snipped for Brevity -->
<item>
<title>FeedForAll's Show Tunes and...
|
by: whiteideal |
last post by:
hay, guys, i just want to create a svg file according to my data, but
i don't know whether there is some opensouce lib to do such things.
Can you tell me about it? Thanks.
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |