Sponsored Content
Top Forums Shell Programming and Scripting How to get exact match sentences? Post 302227741 by vanitham on Friday 22nd of August 2008 12:03:30 AM
Old 08-22-2008
Quote:
Originally Posted by era
I'm afraid it's still not entirely clear what the problem is. Can you show the $regex and the text you are matching it against, and where you are expecting it to match?
Hi,

Ya sure i will tell u!!

$word="RNA binding protein";

Code:
$sent="Protein modeling studies reveal that the RG-rich region is part of a three to four strand antiparallel beta-sheet, which in other RNA binding protein functions as a platform
for nucleic acid interactions.

Heterogeneous nuclear ribonucleoparticle (hnRNP) proteins form a family of RNA binding proteins (RBPs) that coat nascent pre-mRNAs.

Finally, we have found that Pumilio2, a member of the PUF family of RNA-binding proteins, is highly concentrated at the vertebrate neuromuscular junction.

PUF proteins comprise a highly conserved family of sequence-specific RNA-binding protein that regulate target mRNAs.";

my $regex = $word;

$regex =~ s/\s+/[- \\s]/g;

# print all lines matching $regex
while ($sent =~ m/(.*$regex.*)/go) { print "$1\n";

$sent=~s/(\b$regex\b)/<span style="background-color:#E1FF77">$1<\/span>/img

print $sent;

 }

It has to highlight $word("RNA binding protein" or "RNA binding proteins" OR "RNA-binding protein" OR "RNA-binding proteins") in sentences!!

How that can be done?

With regards
Vanitha
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Exact Match thru grep ?????

hey..... i do have text where the contents are like as follows, FILE_TYPE_NUM_01=FILE_TYPE=01|FILE_DESC=Periodic|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=B FILE_TYPE_NUM_02=FILE_TYPE=02|FILE_DESC=NCTO|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=M... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

2. Shell Programming and Scripting

How to match all array contents and display all highest matched sentences in perl?

Hi, I have an array with 3 words in it and i have to match all the array contents and display the exact matched sentence i.e all 3 words should match with the sentence. Here are sentences. $arr1="Our data suggests that epithelial shape and growth control are unequally affected depending... (5 Replies)
Discussion started by: vanitham
5 Replies

3. Shell Programming and Scripting

exact match in Perl

Hi By using select clause I'm trying to pull out the rows to a variable. If the variable has 0 row(s) selected then i'm printing some text message else printing some other text message if($xyz =~ m/0 row/) { print "0 rows "; } else { print " There are rows"; } By my problem... (4 Replies)
Discussion started by: pdreddy34
4 Replies

4. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

5. Shell Programming and Scripting

Exact match question

Hi, I have a file like follows . . . White.Jack.is.going.home Black.Jack.is.going.home Red.Jack.is.going.home Jack.is.going.home . . . when I make: cat <file> | grep -w "Jack.is.going.home" it gives: White.Jack.is.going.home Black.Jack.is.going.home Red.Jack.is.going.home... (4 Replies)
Discussion started by: salih81
4 Replies

6. Shell Programming and Scripting

Exact match and #

Hi friends, i am using the following grep command for exact word match: >echo "sachin#tendulkar" | grep -iw "sachin" output: sachin#tendulkar as we can see in the above example that its throwinng the exact match(which is not the case as the keyword is sachin and string is... (6 Replies)
Discussion started by: neelmani
6 Replies

7. UNIX for Dummies Questions & Answers

Interpolation if there is no exact match for value

Dear all, could you help me with following question. There are two datasets (below). I need to find match between BP values from data1 and data2, and add corresponding CM value from data2 into data1. if there is not exact match, the corresponding CM value should be calculated using interpolation.... (20 Replies)
Discussion started by: kush
20 Replies

8. Shell Programming and Scripting

Get the exact match of the string!

Hi All, I am breaking my head in trying to get a command that will exactly match my given string. I have searched net and found few of the options - grep -F $string file grep -x $string file grep "^${string}$" file awk '/"${string}"/ {print $0}' file strangely nothing seems to... (3 Replies)
Discussion started by: dips_ag
3 Replies

9. Shell Programming and Scripting

Grep exact match

Hello! I have 2 files named tacs.tmp and tacDB.txt tacs.tmp looks like this 0 10235647 102700 106800 107200 1105700 tacDB.txt looks like this 100100,Mitsubishi,G410,Handheld,,0,0,0 100200,Siemens,A53,Handheld,,0,0,0 100300,Sony Ericsson,TBD (AAB-1880030-BV),Handheld,,0,0,0... (2 Replies)
Discussion started by: Cludgie
2 Replies

10. Shell Programming and Scripting

awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. $1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies
Bio::Tools::SeqStats(3pm)				User Contributed Perl Documentation				 Bio::Tools::SeqStats(3pm)

NAME
Bio::Tools::SeqStats - Object holding statistics for one particular sequence SYNOPSIS
# build a primary nucleic acid or protein sequence object somehow # then build a statistics object from the sequence object $seqobj = Bio::PrimarySeq->new(-seq => 'ACTGTGGCGTCAACTG', -alphabet => 'dna', -id => 'test'); $seq_stats = Bio::Tools::SeqStats->new(-seq => $seqobj); # obtain a hash of counts of each type of monomer # (i.e. amino or nucleic acid) print " Monomer counts using statistics object "; $seq_stats = Bio::Tools::SeqStats->new(-seq=>$seqobj); $hash_ref = $seq_stats->count_monomers(); # e.g. for DNA sequence foreach $base (sort keys %$hash_ref) { print "Number of bases of type ", $base, "= ", %$hash_ref->{$base}," "; } # obtain the count directly without creating a new statistics object print " Monomer counts without statistics object "; $hash_ref = Bio::Tools::SeqStats->count_monomers($seqobj); foreach $base (sort keys %$hash_ref) { print "Number of bases of type ", $base, "= ", %$hash_ref->{$base}," "; } # obtain hash of counts of each type of codon in a nucleic acid sequence print " Codon counts using statistics object "; $hash_ref = $seq_stats-> count_codons(); # for nucleic acid sequence foreach $base (sort keys %$hash_ref) { print "Number of codons of type ", $base, "= ", %$hash_ref->{$base}," "; } # or print " Codon counts without statistics object "; $hash_ref = Bio::Tools::SeqStats->count_codons($seqobj); foreach $base (sort keys %$hash_ref) { print "Number of codons of type ", $base, "= ", %$hash_ref->{$base}," "; } # Obtain the molecular weight of a sequence. Since the sequence # may contain ambiguous monomers, the molecular weight is returned # as a (reference to) a two element array containing greatest lower # bound (GLB) and least upper bound (LUB) of the molecular weight $weight = $seq_stats->get_mol_wt(); print " Molecular weight (using statistics object) of sequence ", $seqobj->id(), " is between ", $$weight[0], " and " , $$weight[1], " "; # or $weight = Bio::Tools::SeqStats->get_mol_wt($seqobj); print " Molecular weight (without statistics object) of sequence ", $seqobj->id(), " is between ", $$weight[0], " and " , $$weight[1], " "; # Calculate mean Kyte-Doolittle hydropathicity (aka "gravy" score) my $prot = Bio::PrimarySeq->new(-seq=>'MSFVLVAPDMLATAAADVVQIGSAVSAGS', -alphabet=>'protein'); my $gravy = Bio::Tools::SeqStats->hydropathicity($seqobj); print "might be hydropathic" if $gravy > 1; DESCRIPTION
Bio::Tools::SeqStats is a lightweight object for the calculation of simple statistical and numerical properties of a sequence. By "lightweight" I mean that only "primary" sequences are handled by the object. The calling script needs to create the appropriate primary sequence to be passed to SeqStats if statistics on a sequence feature are required. Similarly if a codon count is desired for a frame- shifted sequence and/or a negative strand sequence, the calling script needs to create that sequence and pass it to the SeqStats object. Nota that nucleotide sequences in bioperl do not strictly separate RNA and DNA sequences. By convention, sequences from RNA molecules are shown as is they were DNA. Objects are supposed to make the distinction when needed. This class is one of the few where this distinctions needs to be made. Internally, it changes all Ts into Us before weight and monomer count. SeqStats can be called in two distinct manners. If only a single computation is required on a given sequence object, the method can be called easily using the SeqStats object directly: $weight = Bio::Tools::SeqStats->get_mol_wt($seqobj); Alternately, if several computations will be required on a given sequence object, an "instance" statistics object can be constructed and used for the method calls: $seq_stats = Bio::Tools::SeqStats->new($seqobj); $monomers = $seq_stats->count_monomers(); $codons = $seq_stats->count_codons(); $weight = $seq_stats->get_mol_wt(); $gravy = $seq_stats->hydropathicity(); As currently implemented the object can return the following values from a sequence: o The molecular weight of the sequence: get_mol_wt() o The number of each type of monomer present: count_monomers() o The number of each codon present in a nucleic acid sequence: count_codons() o The mean hydropathicity ("gravy" score) of a protein: hydropathicity() For DNA and RNA sequences single-stranded weights are returned. The molecular weights are calculated for neutral, or not ionized, nucleic acids. The returned weight is the sum of the base-sugar-phosphate residues of the chain plus one weight of water to to account for the additional OH on the phosphate of the 5' residue and the additional H on the sugar ring of the 3' residue. Note that this leads to a difference of 18 in calculated molecular weights compared to some other available programs (e.g. Informax VectorNTI). Note that since sequences may contain ambiguous monomers (e.g. "M", meaning "A" or "C" in a nucleic acid sequence), the method get_mol_wt returns a two-element array containing the greatest lower bound and least upper bound of the molecule. For a sequence with no ambiguous monomers, the two elements of the returned array will be equal. The method count_codons() handles ambiguous bases by simply counting all ambiguous codons together and issuing a warning to that effect. DEVELOPERS NOTES
Ewan moved it from Bio::SeqStats to Bio::Tools::SeqStats Heikki made tiny adjustments (+/- 0.01 daltons) to amino acid molecular weights to have the output match values in SWISS-PROT. Torsten added hydropathicity calculation. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Peter Schattner Email schattner AT alum.mit.edu CONTRIBUTOR - Torsten Seemann Email torsten.seemann AT infotech.monash.edu.au APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ count_monomers Title : count_monomers Usage : $rcount = $seq_stats->count_monomers(); or $rcount = $seq_stats->Bio::Tools::SeqStats->($seqobj); Function: Counts the number of each type of monomer (amino acid or base) in the sequence. Ts are counted as Us in RNA sequences. Example : Returns : Reference to a hash in which keys are letters of the genetic alphabet used and values are number of occurrences of the letter in the sequence. Args : None or reference to sequence object Throws : Throws an exception if type of sequence is unknown (ie amino or nucleic)or if unknown letter in alphabet. Ambiguous elements are allowed. get_mol_wt Title : get_mol_wt Usage : $wt = $seqobj->get_mol_wt() or $wt = Bio::Tools::SeqStats ->get_mol_wt($seqobj); Function: Calculate molecular weight of sequence Ts are counted as Us in RNA sequences. Example : Returns : Reference to two element array containing lower and upper bounds of molecule molecular weight. For DNA and RNA sequences single-stranded weights are returned. If sequence contains no ambiguous elements, both entries in array are equal to molecular weight of molecule. Args : None or reference to sequence object Throws : Exception if type of sequence is unknown (ie not amino or nucleic) or if unknown letter in alphabet. Ambiguous elements are allowed. count_codons Title : count_codons Usage : $rcount = $seqstats->count_codons() or $rcount = Bio::Tools::SeqStats->count_codons($seqobj) Function: Counts the number of each type of codons for a dna or rna sequence, starting at the 1st triple of the input sequence. Example : Returns : Reference to a hash in which keys are codons of the genetic alphabet used and values are number of occurrences of the codons in the sequence. All codons with "ambiguous" bases are counted together. Args : None or sequence object Throws : an exception if type of sequence is unknown or protein. hydropathicity Title : hydropathicity Usage : $gravy = $seqstats->hydropathicity(); or $gravy = Bio::Tools::SeqStats->hydropathicity($seqobj); Function: Calculates the mean Kyte-Doolittle hydropathicity for a protein sequence. Also known as the "gravy" score. Refer to Kyte J., Doolittle R.F., J. Mol. Biol. 157:105-132(1982). Example : Returns : float Args : None or reference to sequence object Throws : an exception if type of sequence is not protein. _is_alphabet_strict Title : _is_alphabet_strict Usage : Function: internal function to determine whether there are any ambiguous elements in the current sequence Example : Returns : 1 if strict alphabet is being used, 0 if ambiguous elements are present Args : Throws : an exception if type of sequence is unknown (ie amino or nucleic) or if unknown letter in alphabet. Ambiguous monomers are allowed. _print_data Title : _print_data Usage : $seqobj->_print_data() or Bio::Tools::SeqStats->_print_data(); Function: Displays dna / rna parameters (used for debugging) Returns : 1 Args : None Used for debugging. perl v5.14.2 2012-03-02 Bio::Tools::SeqStats(3pm)
All times are GMT -4. The time now is 11:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy