<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Perl *PIPERs's pages]]></title>
	<link>https://bioinformaticsonline.com/pages/group/86/all?</link>
	<atom:link href="https://bioinformaticsonline.com/pages/group/86/all?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/pages/view/37592/benchmarking-perl-module</guid>
	<pubDate>Sat, 25 Aug 2018 11:40:42 -0500</pubDate>
	<link>https://bioinformaticsonline.com/pages/view/37592/benchmarking-perl-module</link>
	<title><![CDATA[Benchmarking Perl Module !]]></title>
	<description><![CDATA[<p>The benchmark module is a great tool to know the time the code takes to run. The output is usually in terms of CPU time. This module provides us with a way to optimize our code. With the advent of petascale computing and other multicore processor it is becoming a neccesity to know about the CPU time taken by our perl program.</p><p>This is the simple way to use the module</p><blockquote><p>Example1:</p><p>use Benchmark;</p><p>$first_time = Benchmark-&gt;new;</p><p>our code&hellip;&hellip;</p><p>$second_time = Benchmark-&gt;new;</p><p>$final_difference = timediff($first_time,$second_time);</p><p>print &ldquo;the code took, timestr($final_difference),&rdquo;\n&rdquo;;</p></blockquote><p>that was a very simple way to know the time diff , we can use it to know the time taken by some part of the code in the program.</p><blockquote><p>More sophisticated way:</p><p>use Benchmark;<br />sub first {</p><p>my(arguments) = @_;</p><p>}</p><p>timethese(100, { first =&gt; &lsquo;first_sub(arguments)&rsquo;});</p><p>The first argument to timethese is 100 (evaluate 100 times).</p></blockquote><p>Hope this very small tutorial with Benchmark will help people get started.</p>]]></description>
	<dc:creator>Rahul Nayak</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/pages/view/30867/perl-special-vars-quick-reference</guid>
	<pubDate>Tue, 07 Feb 2017 05:08:47 -0600</pubDate>
	<link>https://bioinformaticsonline.com/pages/view/30867/perl-special-vars-quick-reference</link>
	<title><![CDATA[Perl Special Vars Quick Reference]]></title>
	<description><![CDATA[<table>
<tbody>
<tr>
<td><tt>$_</tt></td>
<td>The default or implicit variable.</td>
</tr>
<tr>
<td><tt>@_</tt></td>
<td>Subroutine parameters.</td>
</tr>
<tr>
<td><tt>$a</tt><br /><tt>$b</tt></td>
<td><a href="http://perldoc.perl.org/functions/sort.html">sort</a>&nbsp;comparison routine variables.</td>
</tr>
<tr>
<td><tt>@ARGV</tt></td>
<td>The command-line args.</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">Regular Expressions</span></td>
</tr>
<tr>
<td><tt>$&lt;digit&gt;</tt></td>
<td>Regexp parenthetical capture holders.</td>
</tr>
<tr>
<td><tt>$&amp;</tt></td>
<td>Last successful match (degrades performance).</td>
</tr>
<tr>
<td><tt>${^MATCH}</tt></td>
<td>Similar to&nbsp;<tt>$&amp;</tt>&nbsp;without performance penalty. Requires /p modifier.</td>
</tr>
<tr>
<td><tt>$`</tt></td>
<td>Prematch for last successful match string (degrades performance).</td>
</tr>
<tr>
<td><tt>${^PREMATCH}</tt></td>
<td>Similar to&nbsp;<tt>$`</tt>&nbsp;without performance penalty. Requires&nbsp;<tt>/p</tt>&nbsp;modifier.</td>
</tr>
<tr>
<td><tt>$'</tt></td>
<td>Postmatch for last successful match string (degrades performance).</td>
</tr>
<tr>
<td><tt>${^POSTMATCH}</tt></td>
<td>Similar to&nbsp;<tt>$'</tt>&nbsp;without performance penalty. Requires&nbsp;<tt>/p</tt>&nbsp;modifier.</td>
</tr>
<tr>
<td><tt>$+</tt></td>
<td>Last paren match.</td>
</tr>
<tr>
<td><tt>$^N</tt></td>
<td>Last closed paren match (last submatch).</td>
</tr>
<tr>
<td><tt>@+</tt></td>
<td>Offsets of ends of successful submatches in scope.</td>
</tr>
<tr>
<td><tt>@-</tt></td>
<td>Offsets of starts of successful submatches in scope.</td>
</tr>
<tr>
<td><tt>%+</tt></td>
<td>Like&nbsp;<tt>@+</tt>, but for named submatches.</td>
</tr>
<tr>
<td><tt>%-</tt></td>
<td>Like&nbsp;<tt>@-</tt>, but for named submatches.</td>
</tr>
<tr>
<td><tt>$^R</tt></td>
<td>Last regexp (?{code}) result.</td>
</tr>
<tr>
<td><tt>${^RE_DEBUG_FLAGS}</tt></td>
<td>Current value of regexp debugging flags. See&nbsp;<tt>use re 'debug';</tt></td>
</tr>
<tr>
<td><tt>${^RE_TRIE_MAXBUF}</tt></td>
<td>Control memory allocations for RE optimizations for large alternations.</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">Encoding</span></td>
</tr>
<tr>
<td><tt>${^ENCODING}</tt></td>
<td>The object reference to the Encode object, used to convert the source code to Unicode.</td>
</tr>
<tr>
<td><tt>${^OPEN}</tt></td>
<td>Internal use: \0 separated Input / Output layer information.</td>
</tr>
<tr>
<td><tt>${^UNICODE}</tt></td>
<td>Read-only Unicode settings.</td>
</tr>
<tr>
<td><tt>${^UTF8CACHE}</tt></td>
<td>State of the internal UTF-8 offset caching code.</td>
</tr>
<tr>
<td><tt>${^UTF8LOCALE}</tt></td>
<td>Indicates whether UTF8 locale was detected at startup.</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">IO and Separators</span></td>
</tr>
<tr>
<td><tt>$.</tt></td>
<td>Current line number (or record number) of most recent filehandle.</td>
</tr>
<tr>
<td><tt>$/</tt></td>
<td>Input record separator.</td>
</tr>
<tr>
<td><tt>$|</tt></td>
<td>Output autoflush. 1=autoflush, 0=default. Applies to currently selected handle.</td>
</tr>
<tr>
<td><tt>$,</tt></td>
<td>Output field separator (lists)</td>
</tr>
<tr>
<td><tt>$\</tt></td>
<td>Output record separator.</td>
</tr>
<tr>
<td><tt>$"</tt></td>
<td>Output list separator. (interpolated lists)</td>
</tr>
<tr>
<td><tt>$;</tt></td>
<td>Subscript separator. (Use a real multidimensional array instead.)</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">Formats</span></td>
</tr>
<tr>
<td><tt>$%</tt></td>
<td>Page number for currently selected output channel.</td>
</tr>
<tr>
<td><tt>$=</tt></td>
<td>Current page length.</td>
</tr>
<tr>
<td><tt>$-</tt></td>
<td>Number of lines left on page.</td>
</tr>
<tr>
<td><tt>$~</tt></td>
<td>Format name.</td>
</tr>
<tr>
<td><tt>$^</tt></td>
<td>Name of top-of-page format.</td>
</tr>
<tr>
<td><tt>$:</tt></td>
<td>Format line break characters</td>
</tr>
<tr>
<td><tt>$^L</tt></td>
<td>Form feed (default "\f").</td>
</tr>
<tr>
<td><tt>$^A</tt></td>
<td>Format Accumulator</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">Status Reporting</span></td>
</tr>
<tr>
<td><tt>$?</tt></td>
<td>Child error. Status code of most recent system call or pipe.</td>
</tr>
<tr>
<td><tt>$!</tt></td>
<td>Operating System Error. (What just went 'bang'?)</td>
</tr>
<tr>
<td><tt>%!</tt></td>
<td>Error number hash</td>
</tr>
<tr>
<td><tt>$^E</tt></td>
<td>Extended Operating System Error (Extra error explanation).</td>
</tr>
<tr>
<td><tt>$@</tt></td>
<td>Eval error.</td>
</tr>
<tr>
<td><tt>${^CHILD_ERROR_NATIVE}</tt></td>
<td>Native status returned by the last pipe close, backtick (`` ) command, successful call to wait() or waitpid(), or from the system() operator.</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">ID's and Process Information</span></td>
</tr>
<tr>
<td><tt>$$</tt></td>
<td>Process ID</td>
</tr>
<tr>
<td><tt>$&lt;</tt></td>
<td>Real user id of process.</td>
</tr>
<tr>
<td><tt>$&gt;</tt></td>
<td>Effective user id of process.</td>
</tr>
<tr>
<td><tt>$(</tt></td>
<td>Real group id of process.</td>
</tr>
<tr>
<td><tt>$)</tt></td>
<td>Effective group id of process.</td>
</tr>
<tr>
<td><tt>$0</tt></td>
<td>Program name.</td>
</tr>
<tr>
<td><tt>$^O</tt></td>
<td>Operating System name.</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">Perl Status Info</span></td>
</tr>
<tr>
<td><tt>$]</tt></td>
<td>Old: Version and patch number of perl interpreter. Deprecated.</td>
</tr>
<tr>
<td><tt>$^C</tt></td>
<td>Current value of flag associated with&nbsp;<strong>-c</strong>&nbsp;switch.</td>
</tr>
<tr>
<td><tt>$^D</tt></td>
<td>Current value of debugging flags</td>
</tr>
<tr>
<td><tt>$^F</tt></td>
<td>Maximum system file descriptor.</td>
</tr>
<tr>
<td><tt>$^I</tt></td>
<td>Value of the&nbsp;<strong>-i</strong>&nbsp;(inplace edit) switch.</td>
</tr>
<tr>
<td><tt>$^M</tt></td>
<td>Emergency Memory pool.</td>
</tr>
<tr>
<td><tt>$^P</tt></td>
<td>Internal variable for debugging support.</td>
</tr>
<tr>
<td><tt>$^R</tt></td>
<td>Last regexp (?{code}) result.</td>
</tr>
<tr>
<td><tt>$^S</tt></td>
<td>Exceptions being caught. (eval)</td>
</tr>
<tr>
<td><tt>$^T</tt></td>
<td>Base time of program start.</td>
</tr>
<tr>
<td><tt>$^V</tt></td>
<td>Perl version.</td>
</tr>
<tr>
<td><tt>$^W</tt></td>
<td>Status of -w switch</td>
</tr>
<tr>
<td><tt>${^WARNING_BITS}</tt></td>
<td>Current set of warning checks enabled by&nbsp;<tt>use warnings;</tt></td>
</tr>
<tr>
<td><tt>$^X</tt></td>
<td>Perl executable name.</td>
</tr>
<tr>
<td><tt>${^GLOBAL_PHASE}</tt></td>
<td>Current phase of the Perl interpreter.</td>
</tr>
<tr>
<td><tt>$^H</tt></td>
<td>Internal use only: Hook into Lexical Scoping.</td>
</tr>
<tr>
<td><tt>%^H</tt></td>
<td>Internaluse only: Useful to implement scoped pragmas.</td>
</tr>
<tr>
<td><tt>${^TAINT}</tt></td>
<td>Taint mode read-only flag.</td>
</tr>
<tr>
<td><tt>${^WIN32_SLOPPY_STAT}</tt></td>
<td>If true on Windows&nbsp;<tt>stat()</tt>&nbsp;won't try to open the file.</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">Command Line Args</span></td>
</tr>
<tr>
<td><tt>ARGV</tt></td>
<td>Filehandle iterates over files from command line (see also&nbsp;<tt>&lt;&gt;</tt>).</td>
</tr>
<tr>
<td><tt>$ARGV</tt></td>
<td>Name of current file when reading &lt;&gt;</td>
</tr>
<tr>
<td><tt>@ARGV</tt></td>
<td>List of command line args.</td>
</tr>
<tr>
<td><tt>ARGVOUT</tt></td>
<td>Output filehandle for -i switch</td>
</tr>
<tr>
<td colspan="2" align="center"><span style="font-size: xx-small;">Miscellaneous</span></td>
</tr>
<tr>
<td><tt>@F</tt></td>
<td>Autosplit (-a mode) recipient.</td>
</tr>
<tr>
<td><tt>@INC</tt></td>
<td>List of library paths.</td>
</tr>
<tr>
<td><tt>%INC</tt></td>
<td>Keys are filenames, values are paths to modules included via&nbsp;<tt>use, require,&nbsp;</tt>or&nbsp;<tt>do</tt>.</td>
</tr>
<tr>
<td><tt>%ENV</tt></td>
<td>Hash containing current environment variables</td>
</tr>
<tr>
<td><tt>%SIG</tt></td>
<td>Signal handlers.</td>
</tr>
<tr>
<td><tt>$[</tt></td>
<td>Array and substr first element (Deprecated!).</td>
</tr>
</tbody>
</table><p>&nbsp;</p><p>See&nbsp;<a href="http://perldoc.perl.org/perlvar.html">perlvar</a>&nbsp;for detailed descriptions of each of these (and a few more) special variables.</p>]]></description>
	<dc:creator>Abhimanyu Singh</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/pages/view/22567/rosalind-problem-solution-with-perl</guid>
	<pubDate>Tue, 09 Jun 2015 23:35:18 -0500</pubDate>
	<link>https://bioinformaticsonline.com/pages/view/22567/rosalind-problem-solution-with-perl</link>
	<title><![CDATA[Rosalind Problem Solution with Perl]]></title>
	<description><![CDATA[<p>Rosalind is a platform for learning bioinformatics and programming through problem solving. <a href="http://rosalind.info/problems/list-view/?location=bioinformatics-textbook-track">Take a tour</a> to get the hang of how Rosalind works.</p><p>Bioinformatics Textbook Track</p><p>Find more about Rosalind puzzle at http://rosalind.info/problems/list-view/?location=bioinformatics-textbook-track</p><p>I will provide solution of all the Rosalind problem with Perl for community.</p><p>Check out the right sidebar for more links ...</p>]]></description>
	<dc:creator>Jit</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/pages/view/11181/perl-one-liner-for-bioinformatician</guid>
	<pubDate>Fri, 30 May 2014 05:49:07 -0500</pubDate>
	<link>https://bioinformaticsonline.com/pages/view/11181/perl-one-liner-for-bioinformatician</link>
	<title><![CDATA[Perl one-liner for bioinformatician !!!]]></title>
	<description><![CDATA[<p>With the emergence of NGS technologies, and sequencing data most of the bioinformaticians mung and wrangle around massive amounts of genomics text. There are several "standardized" file formats (FASTQ, SAM, VCF, etc.) and some tools for manipulating them (fastx toolkit, samtools, vcftools, etc.), there are still times where knowing a little bit of Perl onliner is extremely helpful.</p><p>Perl one-liners are small and awesome Perl programs that fit in a single line of code and they do one thing really well. These things include changing line spacing, numbering lines, doing calculations, converting and substituting text, deleting and printing certain lines, parsing logs, editing files in-place, doing statistics, carrying out system administration tasks, updating a bunch of files at once, and many more. Perl one-liners will make you the shell warrior. Anything that took you minutes to solve, will now take you seconds!<br /><br />perl -pe '$\="\n"'&nbsp; &nbsp;<br />#double space a file<br /><br />perl -pe '$_ .= "\n" unless /^$/' <br />#double space a file except blank lines<br /><br />perl -pe '$_.="\n"x7' <br />#7 space in a line.<br /><br />perl -ne 'print unless /^$/' <br />#remove all blank lines<br /><br />perl -lne 'print if length($_) &lt; 20' <br />#print all lines with length less than 20.<br /><br />perl -00 -pe '' <br />#If there are multiple spaces, delete all leaving one(make the file a single spaced file).<br /><br />perl -00 -pe '$_.="\n"x4' <br />#Expand single blank lines into 4 consecutive blank lines<br /><br />perl -pe '$_ = "$. $_"'<br />#Number all lines in a file<br /><br />perl -pe '$_ = ++$a." $_" if /./' <br />#Number only non-empty lines in a file<br /><br />perl -ne 'print ++$a." $_" if /./' <br />#Number and print only non-empty lines in a file<br /><br />perl -pe '$_ = ++$a." $_" if /regex/' <br />#Number only lines that match a pattern<br /><br />perl -ne 'print ++$a." $_" if /regex/' <br />#Number and print only lines that match a pattern<br /><br />perl -ne 'printf "%-5d %s", $., $_ if /regex/' <br />#Left align lines with 5 white spaces if matches a pattern (perl -ne 'printf "%-5d %s", $., $_' : for all the lines)<br /><br />perl -le 'print scalar(grep{/./}&lt;&gt;)' <br />#prints the total number of non-empty lines in a file<br /><br />perl -lne '$a++ if /regex/; END {print $a+0}' <br />#print the total number of lines that matches the pattern<br /><br />perl -alne 'print scalar @F' <br />#print the total number fields(words) in each line.<br /><br />perl -alne '$t += @F; END { print $t}' <br />#Find total number of words in the file<br /><br />perl -alne 'map { /regex/ &amp;&amp; $t++ } @F; END { print $t }' <br />#find total number of fields that match the pattern<br /><br />perl -lne '/regex/ &amp;&amp; $t++; END { print $t }' <br />#Find total number of lines that match a pattern<br /><br />perl -le '$n = 20; $m = 35; ($m,$n) = ($n,$m%$n) while $n; print $m' <br />#will calculate the GCD of two numbers.<br /><br />perl -le '$a = $n = 20; $b = $m = 35; ($m,$n) = ($n,$m%$n) while $n; print $a*$b/$m' <br />#will calculate lcd of 20 and 35.<br /><br />perl -le '$n=10; $min=5; $max=15; $, = " "; print map { int(rand($max-$min))+$min } 1..$n' <br />#Generates 10 random numbers between 5 and 15.<br /><br />perl -le 'print map { ("a".."z",&rdquo;0&rdquo;..&rdquo;9&rdquo;)[rand 36] } 1..8'<br />#Generates a 8 character password from a to z and number 0 &ndash; 9.<br /><br />perl -le 'print map { ("a",&rdquo;t&rdquo;,&rdquo;g&rdquo;,&rdquo;c&rdquo;)[rand 4] } 1..20'<br />#Generates a 20 nucleotide long random residue.<br /><br />perl -le 'print "a"x50'<br />#generate a string of &lsquo;x&rsquo; 50 character long<br /><br />perl -le 'print join ", ", map { ord } split //, "hello world"'<br />#Will print the ascii value of the string hello world.<br /><br />perl -le '@ascii = (99, 111, 100, 105, 110, 103); print pack("C*", @ascii)'<br />#converts ascii values into character strings.<br /><br />perl -le '@odd = grep {$_ % 2 == 1} 1..100; print "@odd"'<br />#Generates an array of odd numbers.<br /><br />perl -le '@even = grep {$_ % 2 == 0} 1..100; print "@even"'<br />#Generate an array of even numbers<br /><br />perl -lpe 'y/A-Za-z/N-ZA-Mn-za-m/' file <br />#Convert the entire file into 13 characters offset(ROT13)<br /><br />perl -nle 'print uc' <br />#Convert all text to uppercase:<br /><br />perl -nle 'print lc' <br />#Convert text to lowercase:<br /><br />perl -nle 'print ucfirst lc' <br />#Convert only first letter of first word to uppercas<br /><br />perl -ple 'y/A-Za-z/a-zA-Z/' <br />#Convert upper case to lower case and vice versa<br /><br />perl -ple 's/(\w+)/\u$1/g' <br />#Camel Casing<br /><br />perl -pe 's|\n|\r\n|' <br />#Convert unix new lines into DOS new lines:<br /><br />perl -pe 's|\r\n|\n|' <br />#Convert DOS newlines into unix new line<br /><br />perl -pe 's|\n|\r|' <br />#Convert unix newlines into MAC newlines:<br /><br />perl -pe '/regexp/ &amp;&amp; s/foo/bar/' <br />#Substitute a foo with a bar in a line with a regexp.</p><p>Reference/Sources:</p><p>http://genomics-array.blogspot.in/2010/11/some-unixperl-oneliners-for.html</p><p><a href="http://genomespot.blogspot.com/2013/08/a-selection-of-useful-bash-one-liners.html">http://genomespot.blogspot.com/2013/08/a-selection-of-useful-bash-one-liners.html</a></p><p><a href="http://biowize.wordpress.com/2012/06/15/command-line-magic-for-your-gene-annotations/">http://biowize.wordpress.com/2012/06/15/command-line-magic-for-your-gene-annotations/</a></p><p><a href="http://genomics-array.blogspot.com/2010/11/some-unixperl-oneliners-for.html">http://genomics-array.blogspot.com/2010/11/some-unixperl-oneliners-for.html</a></p><p><a href="http://bioexpressblog.wordpress.com/2013/04/05/split-multi-fasta-sequence-file/">http://bioexpressblog.wordpress.com/2013/04/05/split-multi-fasta-sequence-file/</a></p>]]></description>
	<dc:creator>Abhimanyu Singh</dc:creator>
</item>

</channel>
</rss>