RE: regexp matching- real simple!-GOT IT!

2003-11-13 Thread Nandita Mullapudi
Thanks,
-Nandita

-Original Message-
From: Nandita Mullapudi [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 13, 2003 5:16 PM
To: [EMAIL PROTECTED]
Subject: regexp matching- real simple!
This has to be really easy- but I cant get it to work:
I want my script to carry out a loop only if the number stored in
$diff is positive,
so i say
if ($diff =~m/^[-\d+]/) {blah blah}
but it won't work. why?
TIA
-Nandita
--

   Is the number stored as a string?  Probably not.  Why not use:
   if ($diff > 0) {blah blah}
Chris.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


regexp matching- real simple!

2003-11-13 Thread Nandita Mullapudi
This has to be really easy- but I cant get it to work:
I want my script to carry out a loop only if the number stored in 
$diff is positive,
so i say
if ($diff =~m/^[-\d+]/) {blah blah}
but it won't work. why?
TIA
-Nandita

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


previous element in a list

2003-10-17 Thread Nandita Mullapudi
 I have a list of elements-  and for every element in the
list, I want to carry out an operation with the previous
element or the next one, as the case might be, how do I tell
perl to look at the previous element?
t.i.a
-Nandita

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



was re readline() on closed filehandle FILE

2003-02-11 Thread Nandita Mullapudi

i  just found  the problem- bad formatting of filenames in my list of
files..
thanks!
-nandita



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




readline() on closed filehandle FILE

2003-02-11 Thread Nandita Mullapudi

Hi all,
am using the following script to parse a long list of files. funnily
enough, it works fine when i try a couple sample files, but when i'm
using a long list of files, it comes up with this error:

readline() on closed filehandle FILE at hashing22.pl line 29,  line
13 (#1)
(W closed) The filehandle you're reading from got itself closed
sometime
before now.  Check your logic flow.

i dont know what could be causing this- any ideas? 

here's the script:
#!/usr/bin/perl-w   
# takes a file where the first line specifies query length, puts in ahash   
# the seqid and numbers listed, adds up the numbers, divides by qlen
# and give len coverage.

use diagnostics;

$out_dir = "post_parsing_len_cov_files";
mkdir $out_dir, 0777 unless (-e $out_dir);
$| = 1;

$files= "./listofnames2";

open (FH,"$files") or die "cannot create list :$!";

while () {

push (@list, $_);
}

foreach  (@list) {
$filename=$_;

open (FILE, $filename);

open (HASH_OUT, ">$out_dir/$filename.stats");

my %hash;
while ()
{
if (/^Query : (.*)\S/m){
$qname = "$1";
print HASH_OUT "Query : $qname\n";
}
else
{
if (/^qlen = (\d+)/m){
 $qlen = "$1";
 print HASH_OUT "querylen = $qlen\n";
}
else
{@line = split (/\n/);
 foreach $line (@line){
($key,$value) = split (/:/);
$hash {$key} = $value;
#print " $value";   
@nums = split (" ",$value);
#print "$key: @nums";   

$tot = &total(@nums);
$cov = $tot/$qlen * 100 ;
if ($cov >= 50){
 print  HASH_OUT "$key : $cov\n";
}}}
}}}

close FILE;

sub total {
my $sum;
foreach (@_){
$sum += $_;
}
$sum;
}
--
a typical file to be read by this script is would look like this:

Query : MAL13P1.227_ubiquitin-conjugatin
qlen = 278

>CpType1H_3652:111 81
>CpIowa_1214.266:111 121
>CpGSS_AQ842837:98
>CpType1H_3631:118
>CpIowa_1214.272:118 74 26
>CpIowa_1214.275:77 90 141 17 10 17
>CpEST_AA390251:117
>CpEST_AA390240:102
>CpType1H_3267:77 143
>CpGSS_AQ842682:98

------
SOME files also don't have any lines in them after the first two.
any suggestions on improving my long winded coding skills (or lack
thereof) are most welcome.

thanks,
-nandita


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




picking numbers out of a file and operating on them (fwd)

2002-12-16 Thread Nandita Mullapudi

How does one tell perl to perform mathematical operations?
I have a file with a series of items like this:
>BLAH1
Length = 500
Identities = 20/100.

>BLAH2
Length = 400
Identities = 30/70

For each item called BLAH, I want to pick the denominator in Identites and
divide by Length and calculate percentage.
Eg. for BLAH1: 100/500 * 100 = 20%
and later , print all BLAHs for which the value is >50%.

I csn write reg exps to find the numbers i am interested in, but am not
sure how to go further..

thanks,
-nandita






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




picking numbers out of a file and operating on them

2002-12-16 Thread Nandita Mullapudi

How does one tell perl to perform mathematical operations?
I have a file with a series of items like this:
>BLAH1
Length = 500
Identities = 20/100.

>BLAH2
Length = 400
Identities = 30/70

For each item called BLAH, I want to pick the denominator in Identites and
divide by Length and calculate percentage.
Eg. for BLAH1: 100/500 * 100 = 20%
and later , print all BLAHs for which the value is >50%.

I csn write reg exps to find the numbers i am interested in, but am not
sure how to go further..

thanks,
-nandita





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




HTML::SimpleLinkExtor

2002-11-29 Thread Nandita Shenvi
Hallo All,

I tried to solve my problem using HTML::SimpleLinkExtor and 
HTML::LinkExtor.In both cases I got a similar error message.

my scrpit is as follows:
#!/usr/bin/perl -w



   use strict;
   use HTML::TreeBuilder;  #Parser that builds HTML 
syntax
  tree
   use HTTP::Request::Form;  #Construct HTTP::Request 
objects for
  Form 
processing
   use HTML::Parse;
   use HTTP::Request::Common;#Construct common HTTP::Request 
objects
   use LWP::UserAgent;  #Provides an object for 
clients,
   UserAgent object acts as a 
browser
   use LWP::Simple;
   use URI::URL;
   use HTML::SimpleLinkExtor;   #Module to extract Links
   use Data::Dumper;
   use HTTP::Headers;

   # Upload the Website
   my $url = url 'http://some_host/navitune.html';
   my $ua = new LWP::UserAgent;# Create a 
LWP::UserAgent
   object
   $ua->requests_redirectable ( ['POST'] );# Add METHOD POST for
 redirection
   my $res = $ua->request(POST $url);


   # Parse the website and extract the Form
   my $tree = new HTML::TreeBuilder->parse( $res->content);
$tree->eof();  #Signals 
that
  you are finished with parsing content into 
the tree
   my @forms = @{ $tree->extract_links('FORM') };

   # The first Form
   my $f = HTTP::Request::Form->new( $forms[0][1], $url );  #Constructs a 
new
 form processor
  #$f->dump(); # Prints the extrachted Form on the STDOUT

   # Fill and Send the Form
   $f->field( 'wav_file', 'st11.wav' );# retrieves or sets a 
field-value ,
   where the fieldname =wav_file 
,fieldvalue
   = st11.wav, which is also the file to be 
Uploaded

   my $response = HTTP::Response->new;
   $response = $ua->request($f->press('submit')); # Practically it clicks 
the
  Submit button and the form is 
sent.

   # Response from the Serverside
 $response->as_string();  #as_string is a method of 
HTTP::Request.It
 returns the text version of the request 
object
 as a string with \n placed after each 
line.

 # Parse the website and extrach the first three Links using 
HTML::LinkExtor
my $linkparser = HTML::SimpleLinkExtor->new();   #Create
SimpleLinkExtor 
object
$linkparser->parse($response);#Parse 
response

   my  @all_links = $linkparser->links;#Gets a list 
if links

   print Dumper \@all_links;   #Print list of links out



when i execute this script, I get this: $VAR1 = [ ];

I donot have much experience in perl programming, so i cannot figure out the 
mistake or am I doing some mistake in my scrpit ?

I would be thankful if somebody could invest time to answer my question.

thanks in advance
nandita



Nandita Shenvi
Appartment Nr. 707
Westhoffstr. 15
44791 Bochum
Germany
0234/5844456



_
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



LWP::UserAgent

2002-11-27 Thread Nandita Shenvi
Hi all,

I have a perl script that fills submits a HTML form with METHOD POST and 
input type file.

#!/usr/bin/perl -w


   use strict;
   use HTML::TreeBuilder;
   use HTTP::Request::Form;
   use LWP::UserAgent;
   use URI::URL;


   # Upload the Website
   my $url = url 'http://some host/navitune.html';
   my $ua = new LWP::UserAgent;
my $res = $ua->simple_request(POST $url);

   # Parse the website and extrach the Form
   my $tb = new HTML::TreeBuilder->parse( $res->content);
   my @forms = @{ $tb->extract_links('FORM') };

   # The first Form
   my $f = HTTP::Request::Form->new( $forms[0][1], $url );
   $f->dump(); # Prints the extrachted Form on the STDOUT

   # Fill and Send the Form
   $f->field( 'wav_file', 'st11.wav' );# wav_file is the name of the 
input
   field and st11.wav is the file 
to be
Uploaded


my $response = $ua->request($f->press('submit'));


  # Response from the Serverside
print $response->as_string;

The webserver should send me a list of macthes but i get a response saying :



302 Found

Found
The document has moved http://somemhost/cgi-bin/navitune_web?2+input2.wav";>here.



I think there is some problem with redirect, because when I go to:
http://somemhost/cgi-bin/navitune_web?2+input2.wav

i have the list there, but I would like to store th elist straight away in a 
file.
I have tried using methods from LWP::UserAgent like simple_request and 
redirect_ok but it did not work.

I would be gratefull for anyhelp, thanks for ur time

nandita



_
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



html::form problems

2002-11-25 Thread Nandita Shenvi
Hallo All,

I have checked the mailing list and some where in 1999 a person had a 
similar problem and i could not find any appropriate answer to the questions 
that he had.
anyway, i will try to explain:
I want to write  a Perl program to upload a file to a web server. Please 
note that I'm NOT looking for a script to create a html form with  in it,
and I'm NOT looking for a cgi-script to handle the server side of the 
upload.There exist a upload.c program on the webserver. What I'm looking for 
is a standalone program  that connects to a web server and uploads a file.


I tried to solve the problem using LWP::UserAgent.


my scrpit is as follows:

#!/usr/bin/perl -w


use LWP::UserAgent;
use HTML::Form;
use HTTP::Request;
use URI::URL;

$url = new URI::URL("http://some host");

$ua = new LWP::UserAgent;
$req = new HTTP::Request(POST, 'http://some host/navitune.html');

	   ;
$resp = $ua->request($req)->as_string();
print "$resp\n";


this print out the whole html , i would like to fill the form in the HTML 
and send it to the webserver.

I am pretty new in perl and would be grateful for ur help.

thanks
nandita

_
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



problems with variables

2002-11-19 Thread Nandita Shenvi


hallo All,

My problem, i will explain in terms of an example:

I have variable $e-mail the value of the var is an e-mail address, now I 
would like to to store the value of the variable  under another name for 
example email_id001 or email_id$i, where $i is just a interger.

The problem may seem simple to many of u, but i do not have much experience 
in perl and would be rather grateful for ur help.

thanks
nandita

Nandita Shenvi
Appartment Nr. 707
Westhoffstr. 15
44791 Bochum
Germany
0234/5844456



_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Problem with Mail::MboxParser

2002-11-18 Thread Nandita Shenvi

Hallo All,

I am new in perl and will be grarefull for any help.
my perl script is as follows:

#!/usr/bin/perl -w


use lib "/home/shenvi/share/man/man3";


use IO;
use Mail::Internet;
use MIME::Tool;
use Mail::MboxParser::Mail;
use Mail::MboxParser;






#USE OF Mail::MboxParser

 my $mb =  Mail::MboxParser->new("(\*STDIN)", decode => 'HEADER');

for my $msg ($mb->get_message) {

  print $msg->header->{FROM}, "\n";
  $msg->store_all_attachment('/home/shenvi/perl/tmp');

  }


when i try to run this scrpit  I keep on getting this error:
Error: The filename you passed to open() does not refer to an existing file
at Teststrip.PL line 31

in the above case line 31 is
my $mb =  Mail::MboxParser->new("(\*STDIN)", decode => 'HEADER');



thanks
nandita
Nandita Shenvi
Appartment Nr. 707
Westhoffstr. 15
44791 Bochum
Germany
0234/5844456



_
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



parsing out contents

2002-09-17 Thread Nandita Mullapudi

I have a parsed output in a single file, that looks like this

Pf_sumthing.bln

blah
blah

Pf_sumthingelse.bln

blah
blah

and so on, 
I want to parse this file such that i create 80 or as many little files,
each has the filename as  its respective Pf_something and content has the
blah blah.

can anybody point me in the right way? this is what i've been trying to do
-use  split (/Pf.*\w/) and try to separate the contents..but i'm not
getting there..

t.i.a.
nandita



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: printing output to a file

2002-09-09 Thread Nandita Mullapudi


Thanks ALL for the quick help! i realised my mistake, "open" shd be
outside the loop..
:) :) (scripts that work, very pleasing!)
nandita



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




printing output to a file

2002-09-09 Thread Nandita Mullapudi

hello list
i am trying to print the output of a parsing script to a file- the way it
is right now, the print commands are within a foreach loop, and it prints
to the screen. in order to get the entire output into a file, i'm using a
simple set of commands like so:

foreach my $key (keys %alignments) {
print "$key\n\n", $alignments{$key}, "\nXXX\n";

open (OUT, '>outputfile.txt') or die "couldn't";
print OUT "$key\n\n", $alignments{$key}, "\nXXX\n"
}

print $ending_annotation;
exit;

the output to the screen prints the entire output correctly, but when i
open the file output.txt i get only the last item in my output, not the
entire list..

any help appreciated..

many thanks
nandita.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: inserting a single word in every file

2002-09-05 Thread Nandita Mullapudi

Hi
Thanks alot for your help, i finally got my word inserted just once in
every file (was re ALIGNMENTS..)
yea...am kinda slooow! :)
nandita



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: inserting a single word in every file

2002-08-21 Thread Nandita

Thanks, but I forgot to mention in the beginning that i need to make this
modification only ONCE in my file- the  ">" character comes up every few
lines, but I only want the title "ALIGNMENTS" in the beginning..i.e, it
shd not replace all the ">"s in my file..
?
sorry about that!
-thanks,
nandita




On Wed, 21 Aug 2002, Sudarshan Raghavan wrote:

> On Tue, 20 Aug 2002, Nandita wrote:
> 
> > Thanks for your message, this is how it looks:
> > 
> > beginning of file :
> > 
> >  Reading  High Probability Sequences producing High-scoring Segment Pairs:
> >   Frame Score  P(N)N
> > 
> > EMBL:B88446  CpG0200B CpIOWAgDNA1 Cryptosporidium parv... +375  0.391
> > EMBL:AQ935741  CpG2625B CpIOWAgDNA1 Cryptosporidium pa... +174  0.631
> > EMBL:AQ855708  CpG1711B CpIOWAgDNA1 Cryptosporidium pa... -171  0.891
> > EMBL:AQ935455  CpG2480A CpIOWAgDNA1 Cryptosporidium pa... +269  0.971
> > EMBL:AQ450103  58A04.x1 CpIOWAM13mp18gDNA1 Cryptos... -169  0.981
> > EMBL:AQ254466  CpG0842A CpIOWAgDNA1 Cryptosporidium pa... +268  0.991
> > EMBL:AQ935528  CpG2517B CpIOWAgDNA1 Cryptosporidium pa... -267  0.9981
> > EMBL:AQ854869  CpG2093B CpIOWAgDNA1 Cryptosporidium pa... +267  0.9981
> > EMBL:AQ450236  59E03.x1 CpIOWAM13mp18gDNA1 Cryptos... -165  0.1
> > EMBL:AQ003639  CpG0296A CpIOWAgDNA1 Cryptosporidium pa... +25 0.01
> > 
> > "ALIGNMENTS:"
> > 
> > >EMBL:B88446  CpG0200B CpIOWAgDNA1 Cryptosporidium parvum genomic, genomic
> > survey sequence.
> > Length = 508

>EMBL AQ935528 Cp
above is the word "ALIGNMENTS:" which is not present and which i'd like
to
> > add in each file. i figure i'd have to write out a reg exp- something like
> > "newline followed by ">" ...but am not able to get a good start..-and dont
> > know how to go abt the actual task- figured it had to do with "printing
> > to" a variable in which i stored the file value...
> > am chewing on it..
> 
> You don't have to check for the newline just a if (/^>/) would do
> This assumes that the files to be modified are given in the command line
> If you are getting it some place else, empty @ARGV and add these files to 
> @ARGV.
> 
> #!/usr/local/bin/perl -w
> use strict;
> 
> $^I = '~'; # perldoc perlvar, inplace edit and creates a backup filename~
> while (<>) {
> print "ALIGNMENT:\n" if (/^>/);
> print;
> }
> 
> The same can also be done as an oneliner
> perl -i~ -pe 'print "ALIGNMENTS:\n" if (/^>/);' *.txt
> 
> Note: This will create a backup of all the files it processes, for e.g.
> if the file names1.txt the original file will be backed up as names1.txt~,
> the same as above.
> 
> perldoc perlrun and read through the sections that explains these flags.
> You can replace the *.txt with the list of files that you want modified.
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




inserting a single word in every file

2002-08-19 Thread Nandita

Hello all,
I have a list of files, and need to insert a word somewhere in the middle-
the files begin with a list of sequence names followed by alignments for
each sequence, and i'd like to insert the header "ALIGNMENTS" before they
begin..
Any starting ideas /  pointers for me?
many thanks
and have a nice day...
-nandita


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




use of uninitialised value..

2002-08-10 Thread Nandita Mullapudi

thanks, all,
the script is working!!
small pleasures of life..
cheers!
-nandita


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




use of uninitialised value...

2002-08-09 Thread Nandita Mullapudi

i'm trying to run a perl script written to parse a file, and it runs fine
the way it is written, however, after making little changes to accomodate
my file, i get inundated with the following message

"Use of uninitialized value in hash element at modif2.pl line 90"

can any1 tell me what this means?
many thanks
nandita 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]