467,114 Members | 1,306 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,114 developers. It's quick & easy.

filehandle

Hello people..I just wanted to know that can we store number of files in a filehandle ..if yes how could we do that???I did write a program but its just parsing result from the file which I'm giving at first position.
Thanx in advance !!
Sep 21 '08 #1
  • viewed: 1453
Share:
7 Replies
KevinADC
Expert 2GB
Post some code, your question is confusing.
Sep 21 '08 #2
I have written this code.The output of this code should be total number of individual bases in both the files.
But the output is showing only total number of bases in first file i.e, pdb.txt.
I hope I made my question clear this time??Let me knw if u want some other information.Thanx in advance!!
Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2. $/=undef;
  3.     $file1='C:\Users\documents\pdb.txt';
  4.     $file2='C:\Users\documents\pdb1.txt';
  5.     @files=($file1,$file2);
  6.     foreach $file(@files)
  7.     {
  8.     open(IN,$file) or "die error opening $file";
  9.     $data=<IN>;
  10.     $data1=reverse $data;
  11.     $data2=length $data1;
  12.     print"\nlength of sequence is $data2\n"; 
  13.     print"\nlength of sequence is $data1\n";
  14.     $a=($data=~tr/a/A/);
  15.     $t=($data=~tr/t/T/);
  16.     $g=($data=~tr/g/G/);
  17.     $c=($data=~tr/c/C/);
  18.  
  19.     $total=($a+$t+$g+$c);
  20.     }
  21.  
  22. print"The total number of adenine   are : $a\n";
  23. print"The total number of Thymine  are : $t\n";
  24. print"The total number of Guanine  are : $g\n";
  25. print"The total number of Cytosine are : $c\n";
  26. print"The total bases are $total";
  27.  
Sep 26 '08 #3
KevinADC
Expert 2GB
probably you need to change this line:

Expand|Select|Wrap|Line Numbers
  1. $total=($a+$t+$g+$c);
that overwrites the value of $total instead of summing all the values across all files:

try using "+=" instead of "=":

Expand|Select|Wrap|Line Numbers
  1. $total += ($a+$t+$g+$c);
Same for all of these if you want a sum across all files:

Expand|Select|Wrap|Line Numbers
  1. $a += ($data=~tr/a/A/);
  2. $t += ($data=~tr/t/T/);
  3. $g += ($data=~tr/g/G/);
  4. $c += ($data=~tr/c/C/);
  5.  
Sep 26 '08 #4
yah...now its working...but not giving correct result... coz if I have 10 letters /bases in one of the file its showing 16...why??And how do I remove it??
Sep 26 '08 #5
KevinADC
Expert 2GB
Without seeing your data how do you expect me or anyone to know?
Sep 26 '08 #6
I have two files having just lines of bases...like this
AGTGCCGTA and no other lines....
Sep 27 '08 #7
KevinADC
Expert 2GB
I have two files having just lines of bases...like this
AGTGCCGTA and no other lines....
There is no way to debug the problem when you post one line of data. Post the real data you say gives incorrect results.
Sep 27 '08 #8

Post your reply

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

Similar topics

1 post views Thread by Eduard W. Lohmann | last post: by
2 posts views Thread by Bill | last post: by
1 post views Thread by Wijaya Edward | last post: by
5 posts views Thread by Cliff Martin | last post: by
1 post views Thread by Zairay@gmail.com | last post: by
1 post views Thread by Jeff Williams | last post: by
3 posts views Thread by onlineviewer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.