Sponsored Content
Top Forums Shell Programming and Scripting Round values only when it's numerics Post 303012149 by nengcheng on Tuesday 30th of January 2018 01:10:15 PM
Old 01-30-2018
Quote:
Originally Posted by Yoda
sprintf is an awk string function. For further reference check: String Functions
Code:
sprintf(format, expression1, ...)
Return (without printing) the string that printf would have printed out with the same arguments

So I am using this function to format and then assign the result instead of printing.
Great, that's an elegant solution.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Conversion to display leading zeros for numerics

I have the following script (which works fine), escept I don't know how to make the MONTH and DAY show up with leading zeros. I have a statement (not in this script) which will show this in a YYYYMMDD format, but the script makes the MONTH and DAY fields show single digits. For today, as an... (4 Replies)
Discussion started by: dsimpg1
4 Replies

2. UNIX for Dummies Questions & Answers

how to round a value

Hello, In a unix shell script,i want to round a variabele to a nearest number Ex: set count=104.4 How can i round that to 105.? Thanks, Sateesh (2 Replies)
Discussion started by: kotasateesh
2 Replies

3. Shell Programming and Scripting

round in KSH

Is there an easy way to round a number up in Korn shell? ie. 10.4 --> 11 Thanks. (6 Replies)
Discussion started by: here2learn
6 Replies

4. Shell Programming and Scripting

round a number

In a shell script - How do I round a decimal number (contained in a variable) to the nearest whole number? (2 Replies)
Discussion started by: achieve
2 Replies

5. Shell Programming and Scripting

Drop records with non-numerics in field X

I have tab delimited file and need to remove all records prior to sort, that have non-numerics in the Field 2. valid/invalid field 2 data examples are: " 123" valid "1 23" invalid " NOPE" invalid I've tried this awk it does not recognize tab as the delimiter or check... (3 Replies)
Discussion started by: akxeman
3 Replies

6. Shell Programming and Scripting

round decimal values and use in loops

i have a file in which 3 values are stored like --4.72 4.42 3.86 what i wanna do is that take read each value and compare with a fixed value say 5 but cant do so as i am getting an error for the same. please check the code cat /home/nsadm/auto/Logging/uptime.txt| while read a b c do if... (2 Replies)
Discussion started by: gemnian.g
2 Replies

7. Shell Programming and Scripting

Round up the decimals

Hi All, I would like to do the following in the shell script 561.76 to 562 I tried using this echo 'scale=0; 749 * 75 /100 ' | bc but just returned only 561 Please help me . I appreciate your help Thanks rajeevm (13 Replies)
Discussion started by: rajeevm
13 Replies

8. Shell Programming and Scripting

How to extract 4th field if numerics?

I have a file which contains fields comma separated & with each field surrounded by quotes. The 4th field contains either a serial number, the text ABC, the text XYZ or it's blank. I want to only extract records which have a serial number. Here's some sample data: > cat myfile... (4 Replies)
Discussion started by: CHoggarth
4 Replies

9. Shell Programming and Scripting

Grepping non-alpa-numerics from first column only

I have data in the following tab-separated format (consists of 200 columns all together, this is just a sampling) </s> 0.001701 0.002025 0.002264 0.001430 -0.001300 . -0.205240 0.177341 -0.426209 -0.661049 -0.048884 0.027032 the -0.159145 0.084377 0.056968 0.050934 0.160689 of -0.230698... (7 Replies)
Discussion started by: owwow14
7 Replies
Bio::SearchIO::Writer::HTMLResultWriter(3pm)		User Contributed Perl Documentation	      Bio::SearchIO::Writer::HTMLResultWriter(3pm)

NAME
Bio::SearchIO::Writer::HTMLResultWriter - write a Bio::Search::ResultI in HTML SYNOPSIS
use Bio::SearchIO; use Bio::SearchIO::Writer::HTMLResultWriter; my $in = Bio::SearchIO->new(-format => 'blast', -file => shift @ARGV); my $writer = Bio::SearchIO::Writer::HTMLResultWriter->new(); my $out = Bio::SearchIO->new(-writer => $writer); $out->write_result($in->next_result); # to filter your output my $MinLength = 100; # need a variable with scope outside the method sub hsp_filter { my $hsp = shift; return 1 if $hsp->length('total') > $MinLength; } sub result_filter { my $result = shift; return $hsp->num_hits > 0; } my $writer = Bio::SearchIO::Writer::HTMLResultWriter->new (-filters => { 'HSP' => &hsp_filter} ); my $out = Bio::SearchIO->new(-writer => $writer); $out->write_result($in->next_result); # can also set the filter via the writer object $writer->filter('RESULT', &result_filter); DESCRIPTION
This object implements the SearchWriterI interface which will produce a set of HTML for a specific Bio::Search::Report::ReportI interface. See Bio::SearchIO::SearchWriterI for more info on the filter method. 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 the Bioperl mailing list. 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 of the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Jason Stajich Email jason-at-bioperl-dot-org CONTRIBUTORS
Gary Williams G.Williams@hgmp.mrc.ac.uk APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : my $obj = Bio::SearchIO::Writer::HTMLResultWriter->new(); Function: Builds a new Bio::SearchIO::Writer::HTMLResultWriter object Returns : Bio::SearchIO::Writer::HTMLResultWriter Args : -filters => hashref with any or all of the keys (HSP HIT RESULT) which have values pointing to a subroutine reference which will expect to get a -nucleotide_url => URL sprintf string base for the nt sequences -protein_url => URL sprintf string base for the aa sequences -no_wublastlinks => boolean. Do not display WU-BLAST lines even if they are parsed out. Links = (1) remote_database_url Title : remote_database_url Usage : $obj->remote_database_url($type,$newval) Function: This should return or set a string that contains a %s which can be filled in with sprintf. Returns : value of remote_database_url Args : $type - 'PROTEIN' or 'P' for protein URLS 'NUCLEOTIDE' or 'N' for nucleotide URLS $value - new value to set [optional] to_string Purpose : Produces data for each Search::Result::ResultI in a string. : This is an abstract method. For some useful implementations, : see ResultTableWriter.pm, HitTableWriter.pm, : and HSPTableWriter.pm. Usage : print $writer->to_string( $result_obj, @args ); Argument : $result_obj = A Bio::Search::Result::ResultI object : @args = any additional arguments used by your implementation. Returns : String containing data for each search Result or any of its : sub-objects (Hits and HSPs). Throws : n/a hit_link_desc Title : hit_link_desc Usage : $self->hit_link_desc(&link_function); Function: Get/Set the function which provides an HTML link(s) for the given hit to be used within the description section at the top of the BLAST report. This allows a person reading the report within a web browser to go to one or more database entries for the given hit from the description section. Returns : Function reference Args : Function reference See Also: L<default_hit_link_desc()> default_hit_link_desc Title : default_hit_link_desc Usage : $self->default_hit_link_desc($hit, $result) Function: Provides an HTML link(s) for the given hit to be used within the description section at the top of the BLAST report. This allows a person reading the report within a web browser to go to one or more database entries for the given hit from the description section. Returns : string containing HTML markup "<a href...") The default implementation returns an HTML link to the URL supplied by the remote_database_url() method and using the identifier supplied by the id_parser() method. It will use the NCBI GI if present, and the accession if not. Args : First argument is a Bio::Search::Hit::HitI Second argument is a Bio::Search::Result::ResultI See Also: hit_link_align, remote_database, id_parser hit_link_align Title : hit_link_align Usage : $self->hit_link_align(&link_function); Function: Get/Set the function which provides an HTML link(s) for the given hit to be used within the HSP alignment section of the BLAST report. This allows a person reading the report within a web browser to go to one or more database entries for the given hit from the alignment section. Returns : string containing HTML markup "<a href...") The default implementation delegates to hit_link_desc(). Args : First argument is a Bio::Search::Hit::HitI Second argument is a Bio::Search::Result::ResultI See Also: hit_link_desc, remote_database, id_parser hit_desc_line Title : hit_desc_line Usage : $self->hit_desc_line(&link_function); Function: Get/Set the function which provides HTML for the description information from a hit. This allows one to parse the rest of the description and split up lines, add links, etc. Returns : Function reference Args : Function reference See Also: L<default_hit_link_desc()> default_hit_desc_line Title : default_hit_desc_line Usage : $self->default_hit_desc_line($hit, $result) Function: Parses the description line information, splits based on the hidden x01 between independent descriptions, checks the lines for possible web links, and adds HTML link(s) for the given hit to be used. Returns : string containing HTML markup "<a href...") The default implementation returns an HTML link to the URL supplied by the remote_database_url() method and using the identifier supplied by the id_parser() method. It will use the NCBI GI if present, and the accession if not. Args : First argument is a Bio::Search::Hit::HitI Second argument is a Bio::Search::Result::ResultI See Also: hit_link_align, remote_database, id_parser start_report Title : start_report Usage : $index->start_report( CODE ) Function: Stores or returns the code to write the start of the <HTML> block, the <TITLE> block and the start of the <BODY> block of HTML. Useful for (for instance) specifying alternative HTML if you are embedding the output in an HTML page which you have already started. (For example a routine returning a null string). Returns &default_start_report (see below) if not set. Example : $index->start_report( &my_start_report ) Returns : ref to CODE if called without arguments Args : CODE default_start_report Title : default_start_report Usage : $self->default_start_report($result) Function: The default method to call when starting a report. Returns : sting Args : First argument is a Bio::Search::Result::ResultI title Title : title Usage : $self->title($CODE) Function: Stores or returns the code to provide HTML for the given BLAST report that will appear at the top of the BLAST report HTML output. Useful for (for instance) specifying alternative routines to write your own titles. Returns &default_title (see below) if not set. Example : $index->title( &my_title ) Returns : ref to CODE if called without arguments Args : CODE default_title Title : default_title Usage : $self->default_title($result) Function: Provides HTML for the given BLAST report that will appear at the top of the BLAST report HTML output. Returns : string containing HTML markup The default implementation returns <CENTER> <H1> HTML containing text such as: "Bioperl Reformatted HTML of BLASTP Search Report for gi|1786183|gb|AAC73113.1|" Args : First argument is a Bio::Search::Result::ResultI introduction Title : introduction Usage : $self->introduction($CODE) Function: Stores or returns the code to provide HTML for the given BLAST report detailing the query and the database information. Useful for (for instance) specifying routines returning alternative introductions. Returns &default_introduction (see below) if not set. Example : $index->introduction( &my_introduction ) Returns : ref to CODE if called without arguments Args : CODE default_introduction Title : default_introduction Usage : $self->default_introduction($result) Function: Outputs HTML to provide the query and the database information Returns : string containing HTML Args : First argument is a Bio::Search::Result::ResultI Second argument is string holding literature citation end_report Title : end_report Usage : $self->end_report() Function: The method to call when ending a report, this is mostly for cleanup for formats which require you to have something at the end of the document (</BODY></HTML>) for HTML Returns : string Args : none id_parser Title : id_parser Usage : $index->id_parser( CODE ) Function: Stores or returns the code used by record_id to parse the ID for record from a string. Useful for (for instance) specifying a different parser for different flavours of FASTA file. Returns &default_id_parser (see below) if not set. If you supply your own id_parser subroutine, then it should expect a fasta description line. An entry will be added to the index for each string in the list returned. Example : $index->id_parser( &my_id_parser ) Returns : ref to CODE if called without arguments Args : CODE default_id_parser Title : default_id_parser Usage : $id = default_id_parser( $header ) Function: The default Fasta ID parser for Fasta.pm Returns $1 from applying the regexp /^>s*(S+)/ to $header. Returns : ID string The default implementation checks for NCBI-style identifiers in the given string ('gi|12345|AA54321'). For these IDs, it extracts the GI and accession and returns a two-element list of strings (GI, acc). Args : a fasta header line string algorithm_reference Title : algorithm_reference Usage : my $reference = $writer->algorithm_reference($result); Function: Returns the appropriate Bibliographic reference for the algorithm format being produced Returns : String Args : L<Bio::Search::Result::ResultI> to reference Methods Bio::SearchIO::SearchWriterI Bio::SearchIO::SearchWriterI inherited methods. filter Title : filter Usage : $writer->filter('hsp', &hsp_filter); Function: Filter out either at HSP,Hit,or Result level Returns : none Args : string => data type, CODE reference no_wublastlinks Title : no_wublastlinks Usage : $obj->no_wublastlinks($newval) Function: Get/Set boolean value regarding whether or not to display Link = (1) type output in the report output (WU-BLAST only) Returns : boolean Args : on set, new boolean value (a scalar or undef, optional) perl v5.14.2 2012-03-02 Bio::SearchIO::Writer::HTMLResultWriter(3pm)
All times are GMT -4. The time now is 01:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy