Got it.Thanks.I have been able to retrive all the info i need and in the format that I want. Now I need some light on the following. Here is a snippet again:
gene 410..1750 > > /gene="dnaA" > > /db_xref="EMBL:2632267" > > CDS 410..1825 > > /gene="dnaA" > > /function="initiation of chromosome replication (DNA > > synthesis)" > > /note="alternate gene name: dnaH, dnaJ, dnaK" > > /codon_start=1 > > /transl_table=11 > > /protein_id="CAB11777.1" > > /db_xref="GI:2632268" I have range1..range1 range2..range2 The start of all the 2 range is same.The ending number is differnent.I need to compute the difference in the two and display it with the gene name: example for this snippet: dnaA:75 I need an idea as to how to tie the gene name with the diff. value. Thanks a lot, On 12/4/07, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > minky arora wrote: > > .A part of my file looks like this: > > > > gene 410..1750 > > /gene="dnaA" > > /db_xref="EMBL:2632267" > > CDS 410..1750 > > /gene="dnaA" > > /function="initiation of chromosome replication (DNA > > synthesis)" > > /note="alternate gene name: dnaH, dnaJ, dnaK" > > /codon_start=1 > > /transl_table=11 > > /protein_id="CAB11777.1" > > /db_xref="GI:2632268" > > > > I need to extract the range for gene as well as CDS and compare them. > > > > SO far this is where Ive reached: > > #!/usr/bin/perl > > use warnings; > > use strict; > > my $line; > > my @new; > > my $line1; > > open FILE,"/users/meenaksharora/bio.txt"or die"cannot open $!\n"; > > foreach $line(<FILE>){ > > if($line=~m/gene/) > > [EMAIL PROTECTED]; > > } > > } > > At this point, @new contains one element with the _last_ line containing > the substring 'gene'. > > Maybe you want to anchor the regex: > > if ( $line =~ m/^gene/ ) > --------------------^ > > > foreach $line1(@new){ > > if($line1=~m/(\d)+\.\./) > > { print $line1;print "hello"; > > } > > } > > You may also want to replace those foreach loops with: > > while ( $line = <FILE> ) { > if ( $line =~ /(gene|CDS)\s+(\d+\.\.\d+)/ ) { > print "$1: $2\n"; > } > } > > -- > Gunnar Hjalmarsson > Email: http://www.gunnar.cc/cgi-bin/contact.pl > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/