<?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: All]]></title>
	<link>https://bioinformaticsonline.com/snippets?offset=390</link>
	<atom:link href="https://bioinformaticsonline.com/snippets?offset=390" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/30354/perl-script-to-remove-the-duplicate-sequences-from-multifasta-file</guid>
	<pubDate>Fri, 23 Dec 2016 08:47:47 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/30354/perl-script-to-remove-the-duplicate-sequences-from-multifasta-file</link>
	<title><![CDATA[Perl script to remove the duplicate sequences from multifasta file]]></title>
	<description><![CDATA[<code>use strict;
use Bio::SeqIO;
my %unique;

my $file   = &quot;myseqs.fa&quot;;
my $seqio  = Bio::SeqIO-&gt;new(-file =&gt; $file, -format =&gt; &quot;fasta&quot;);
my $outseq = Bio::SeqIO-&gt;new(-file =&gt; &quot;&gt;$file.uniq&quot;, -format =&gt; &quot;fasta&quot;);

while(my $seqs = $seqio-&gt;next_seq) {
  my $id  = $seqs-&gt;display_id;
  my $seq = $seqs-&gt;seq;
  unless(exists($unique{$seq})) {
    $outseq-&gt;write_seq($seqs);
    $unique{$seq} +=1;
  }
}</code>]]></description>
	<dc:creator>Bulbul</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/30248/dotplot-with-perl</guid>
	<pubDate>Tue, 20 Dec 2016 07:25:01 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/30248/dotplot-with-perl</link>
	<title><![CDATA[DotPlot with Perl]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
use strict;use warnings;
my $i;my $j;my $a;

open (FH1,&#039;&lt;&#039;, &quot;s.fa&quot;);
open (FH2,&#039;&lt;&#039;, &quot;s.fa&quot;);
my $seq1 = do { local $/; &lt;FH1&gt; };
my $seq2 = do { local $/; &lt;FH2&gt; };


my @s1=split(&#039;&#039;,$seq1);
my @s2=split(&#039;&#039;,$seq2);
my @matrix=();

for($i=0;$i&lt;scalar(@s2);$i++)
{
 for($j=0;$j&lt;scalar(@s1);$j++)
 {
  if($s2[$i] eq $s1[$j])
  {
  $matrix[$i][$j]=&quot;.&quot;;
  }
  else
  {
  $matrix[$i][$j]=&quot; &quot;;
  }

 }
}

#Printing matrix of dot plot
open (FHOUT,&quot;&gt;dotplot.txt&quot;) or die &quot;cannot open outfile\n&quot;;
for($a=0;$a&lt;scalar(@s1);$a++)
{
print FHOUT &quot;$s1[$a]&quot;;
}
print FHOUT &quot;\n&quot;;
#print&quot;\n\n&quot;;
for($i=0;$i&lt;scalar(@s2);$i++)
{
print FHOUT &quot;$s2[$i]&quot;;

 for($j=0;$j&lt;scalar(@s1);$j++)
 {
 print FHOUT &quot;$matrix[$i][$j]&quot;;
 }
print FHOUT &quot;\n&quot;;
#print&quot;\n\n&quot;;
}

close FH1;
close FH2;
close FHOUT;</code>]]></description>
	<dc:creator>Abhimanyu Singh</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/30247/dotplot-with-perl-gd</guid>
	<pubDate>Tue, 20 Dec 2016 07:23:52 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/30247/dotplot-with-perl-gd</link>
	<title><![CDATA[DotPlot with Perl GD]]></title>
	<description><![CDATA[<code>#!/usr/local/bin/perl -w
# NOTE: YOU MUST CHANGE THE LINE ABOVE TO POINT TO
# THE FULL PATH OF THE PERL EXECUTABLE ON YOUR SYSTEM.

# System requirements: requires perl and perl modules
# DB_File and GD.pm, available from CPAN.
 
# For usage information, run this program with the flag
# -h.

require v5.6.0;

use GD;
use DB_File;
use strict;
use vars qw/$VERSION/;

BEGIN {

	    $VERSION = &#039;1.0&#039;;

	    if (!defined $GD::VERSION || $GD::VERSION ne 1.32) {
			print STDERR &quot;\n$0:\n&quot;;
			print STDERR &quot;WARNING -- GD VERSION 1.32 REQUIRED.\n&quot;;		
			if (defined $GD::VERSION){
				print STDERR &quot;You have GD version $GD::VERSION.\n&quot;;
				print STDERR &quot;If $0\n&quot;;
				print STDERR &quot;does not work correctly you will\n&quot;;
				print STDERR &quot;have to install GD version 1.32.\n\n&quot;;
		    }
		}

	    if (!defined $DB_File::VERSION || $DB_File::VERSION ne 1.814) {
			print STDERR &quot;\n$0:\n&quot;;
			print STDERR &quot;WARNING -- DB_File VERSION 1.814 REQUIRED.\n&quot;;
			if (defined $DB_File::VERSION){
				print STDERR &quot;You have DB_File version $DB_File::VERSION.\n&quot;;
				print STDERR &quot;If $0\n&quot;;
				print STDERR &quot;does not work correctly you will\n&quot;;
				print STDERR &quot;have to install DB_File version 1.814.\n\n&quot;;
		    }
		}
}

use Getopt::Long;

sub usage();
sub main();
sub print_square($$$$$$$$$$);
sub print_triangle($$$$$$$$$);
sub print_png ($$);
sub revcomp($);


main();

sub usage() {
    print qq/
    
USAGE: $0 -i &lt;in file&gt; [optional args]

OPTIONAL ARGUMENTS:

        -j &lt;2nd file&gt; 
        -o &lt;out file&gt;
        -d &lt;dot file&gt;
        -w &lt;word size&gt; 
        -s &lt;step size&gt;
        -p &lt;pixels&gt;
        -t &lt;title&gt;
          
        -h print this help message


Create a PNG (&quot;portable network graphics&quot;) file
that displays a triangular dot plot of the input
sequence against itself, or a square plot against 
a second sequence with option -j.





&lt;in file&gt;   is a fasta format file from which the
            sequence is taken.

            This is the only required parameter.
			


&lt;2nd file&gt;  is a fasta format file from which a
            second sequence is taken.
	
            default:
            null -- triangular dot plot created           
			


&lt;out file&gt;  is the PNG file created.

            default:
            &lt;in file(s)&gt;_&lt;word_size&gt;_&lt;step_length&gt;_&lt;pixels&gt;.png
			


&lt;dot file&gt;  A database file containing the 
            positions of words of &lt;word size&gt;
            encountered in your sequence.
            This database is not human-readable,
            and can get quite large, so make 
            sure that you have plenty of disk 
            space available. 
            
            Databases size scales linearly 
            with sequence length. With default 
            parameters,databases are are roughly 
            150k per base-pair of sequence.
            
            Complex sequences use more disk
            space than repetitive ones.
			
            default:
            &lt;infile(s)&gt;_&lt;word_size&gt;_&lt;step_length&gt;.dot
			


&lt;word size&gt; is the word size for a match.  A dot
            is printed if there is a perfect match
            of length &lt;word size&gt;.
            
            default:
            &lt;word size&gt; = 100
			


&lt;step size&gt; is the number of bases to move the
            word for each dot.
            
            default:
            &lt;step size&gt; = 1
			


&lt;pixels&gt;    is the width of the plot in pixels and
            defines the resolution of the image.

            default:
            &lt;pixels&gt; = 600
			


&lt;title&gt;     is a title to place in the output.

            default:
            null -- no title appears



If for some reason this program is disrupted during
a run, restart with the same parameters and it will
automatically resume where it left off.

Completed runs can be re-plotted from the existing 
dot file using a different resolution by changing -p

-h causes this message to printed.

(Version $VERSION)

/;
}

sub main() {

	#Define the arguments
    my ($seqfile, $second, $outfile, $dotfile, $word, $step, $pixels, $title, $help);
	
	#Perform Checking -- remind the user that TMTOWTDI.
    if (!GetOptions(
    	&#039;infile=s&#039;  =&gt; \$seqfile,
    	&#039;jfile=s&#039;   =&gt; \$second,
		&#039;wordlen=i&#039; =&gt; \$word,
		&#039;step=i&#039;    =&gt; \$step,
		&#039;outfile=s&#039; =&gt; \$outfile,
		&#039;title=s&#039;   =&gt; \$title,
		&#039;pixels=i&#039;   =&gt; \$pixels,
		&#039;dotfile=s&#039; =&gt; \$dotfile,
		&#039;help&#039;      =&gt; \$help)) {
		usage;
		exit -1;
    }
    
    if ($help) {
		usage;
		exit;
    }
    
	if (!defined $seqfile){
		usage; exit -1;
    }
    
	if (!defined $second){
		print &quot;Creating triangular plot from: $seqfile\n&quot;;
		print &quot;\t use -j to make a square plot\n&quot;;
	}
	
    if (!defined $word){
    	$word = 100;
    	print &quot;Using word size 100\n&quot;;
		print &quot;\tuse -w to set word size\n&quot;;
    }elsif ($word &lt;= 0){
		print STDERR &quot;$0 -w &lt;word size&gt; must be &gt;= 0\n&quot;;
		exit -1;
    }
    
	if (!defined $step){
		$step = 1;
    	print &quot;Using step size 1\n&quot;;
		print &quot;\tuse -s to set step size\n&quot;;
	}elsif ($step &lt;= 0) {
		print STDERR &quot;$0 -s &lt;step length&gt; must be &gt;= 0\n&quot;;
		exit -1;
    }	
    
    if (!defined $pixels){
    	$pixels = 600;
    	print &quot;Using image size 600 pixels\n&quot;;
		print &quot;\tuse -p to set pixels\n&quot;;
	}elsif ($pixels &lt;= 0) {
		print STDERR &quot;$0 -s &lt;pixels&gt; must be &gt;= 0\n&quot;;
		exit -1;
    }	
	
	if (!defined $dotfile) {
		$seqfile =~ m/\/?([^\/\.]+)\.?\w*$/;
		$dotfile = $1;
		if ($second){
			$second =~ m/\/?([^\/\.]+)\.?\w*$/;
			$dotfile .= &quot;_&quot; . $1;
		}
		$dotfile .= &quot;_&quot; . $word . &quot;_&quot; . $step;
		#$dotfile =~ tr/[\.\/]/_/;
		$dotfile .= &quot;.dot&quot;;
		print &quot;Storing matches in: $dotfile\n&quot;;
		print &quot;\tuse -d to name dot file\n&quot;;
    }
		
	if (!defined $outfile){
		$seqfile =~ m/\/?([^\/\.]+)\.?\w*$/;
		$outfile = $1;
		if ($second){
			$second =~ m/\/?([^\/\.]+)\.?\w*$/;
			$outfile .= &quot;_&quot; . $1;
		}
		$outfile .= &quot;_&quot; . $word . &quot;_&quot; . $step . &quot;_&quot; . $pixels;
		#$outfile =~ tr/[\.\/]/_/;
		$outfile .= &quot;.png&quot;;
		print &quot;Printing picture in: $outfile\n&quot;;
		print &quot;\tuse -o to name out file\n&quot;;
    }

	    
    $title = &#039;&#039; unless defined $title;

	#Open the database file -- this makes us fast!
	my %DOT = ();
	dbmopen(%DOT, &quot;$dotfile&quot;, 0666) || die &quot;Cannot open $dotfile: $!&quot;;

	#Define some variables we need
	my ($xlen, $ylen) = (0, 0);
	my ($i, $j, $k, $key) = (0, 0, 0, &quot;&quot;);
	my $seq = &quot;&quot;;
	
	#Start reading the first sequence, avoid a file slurp
	
    open(IN, $seqfile) || die &quot;Cannot open $seqfile: $!&quot;;
    while (&lt;IN&gt;){
    	if (m/^&gt;/){
    		next;
    	}
    	chomp;
    	$k += length $_;
    	$seq .= uc($_);
    	while ($seq &amp;&amp; (($i + $word) &lt; $k) &amp;&amp; ($j + $word) &lt; $k){
    		#wait until we hit the place where we left off!
    		if ($DOT{xpos} &amp;&amp; $i &lt; $DOT{xpos}){
    		}elsif ($i &lt; $j){
    			$DOT{xpos} = $i;
    		}elsif ($i == $j){
    			$DOT{xpos} = $i;
    			$key = substr($seq, 0, $word);
    			#treat Ns as mismatches
    			unless ($key =~ m/N/){
    				if ($DOT{$key}){
    					$DOT{$key} .= &quot;x:$i\t&quot;;
    				}elsif($DOT{revcomp($key)}){
    					$DOT{revcomp($key)} .= &quot;x:$i\t&quot;;
    				}else{
    					$DOT{$key} .= &quot;x:$i\t&quot;;
    				}
    			}
    			$j += $step;
    		}
    		substr($seq, 0, 1) = &quot;&quot;;
    		$i++;
    	}
	    	
	}
	close IN;
	$xlen = $k;
	
	#Is there another sequence?

	    
	if ($second){

		#Looks like there is.
		#Flush out these variables:

		($i, $j, $k, $key) = (0, 0, 0, &quot;&quot;);
		$seq = &quot;&quot;;
		
		#Read the second sequence, avoid a file slurp
		
    	open(IN, $second) || die &quot;Cannot open $second: $!&quot;;	
	    while (&lt;IN&gt;){
	    	if (m/^&gt;/){
	    		next;
	    	}
	    	chomp;
	    	$k += length $_;
	    	$seq .= uc($_);
	    	while ($seq &amp;&amp; (($i + $word) &lt; $k) &amp;&amp; ($j + $word) &lt; $k){
				#wait until we hit the place where we left off!
	    		if ($DOT{ypos} &amp;&amp; $i &lt; $DOT{ypos}){
	    		}elsif ($i &lt; $j){
	    			$DOT{ypos} = $i;
	    		}elsif ($i == $j){
	    			$DOT{ypos} = $i;
	    			$key = substr($seq, 0, $word);
	    			#treat Ns as mismatches
	    			unless ($key =~ m/N/){
	    				if ($DOT{$key}){
	    					$DOT{$key} .= &quot;y:$i\t&quot;;
	    				}elsif($DOT{revcomp($key)}){
	    					$DOT{revcomp($key)} .= &quot;y:$i\t&quot;;
	    				}else{
	    					$DOT{$key} .= &quot;y:$i\t&quot;;
	    				}
	    			}
	    			$j += $step;
	    		}
	    		substr($seq, 0, 1) = &quot;&quot;;
	    		$i++;
	    	}
	    	
	    }
	    close IN;
	    $ylen = $k;
	}
	# Close that DB
	
	dbmclose %DOT;
	
    # Create and print the output.
    
    my ($img, $white, $black, $gray, $margin, $x0, $y0, $x1, $y1);
	$margin = 50;
	$x0 = $y0 = $margin;
	$x1 = $y1 = $pixels - $margin;
    $img = new GD::Image($pixels, $pixels);
    $white = $img-&gt;colorAllocate(255,255,255);
	$black = $img-&gt;colorAllocate(0,0,0);
	$gray = $img-&gt;colorAllocate(187,187,187);
    $img-&gt;interlaced(&#039;true&#039;);
    $img-&gt;string(gdLargeFont, $x0, $y0 - 35, &quot;$title  -w=$word -s=$step&quot;, $black);
	
	
    # Square or Triangle?
    
    if ($second){
    	$img-&gt;string(gdLargeFont, $x0, $y0 - 15, &quot;$xlen bp x $ylen bp&quot;, $black);
    	print_square($img, $x0, $x1, $y0, $y1, $black, $gray, $xlen, $ylen, $dotfile);
    }else{
		$img-&gt;string(gdLargeFont, $x0, $y0 - 15, &quot;$xlen bp&quot;, $black);
		print_triangle($img, $x0, $x1, $y0, $y1, $black, $gray, $xlen, $dotfile);
    }
    
    # Print this thing out
    
    print_png($img, $outfile);
    
    print &quot;Plot Complete!\n&quot;;
} 
 

sub print_square ($$$$$$$$$$){

	my ($img, $x0, $x1, $y0, $y1, $black, $gray, $xlen, $ylen, $dotfile) = @_;
	
	my $del = ($x1 - $x0) / $xlen;
	if ($del &gt; (($y1 - $y0) / $ylen)){
		$del = (($y1 - $y0) / $ylen);
	}	
	my %hash = ();
	my ($xd, $yd, $key, $value);
	my %TEMPFILE = ();
	dbmopen(%TEMPFILE, &quot;$dotfile&quot;, 0666) || die &quot;Can&#039;t open database $dotfile: $!&quot;;
	#avoid slurping again, pull values out one by one!
	while (($key,$value) = each %TEMPFILE){
		if ($key =~ m/[ACGT]+/){
			while ($value =~ m/([xy]):(\d+)\t(.*)/){
				($hash{$1}{$2}, $value) = (1, $3);	
			}
		}
		foreach $xd (keys(%{$hash{x}})){
			foreach $yd (keys(%{$hash{y}})){
				$img-&gt;setPixel(($x0 + ($del * $xd)), ($y0 + ($del * $yd)), $black);
			}
		}
		%hash = ();
	}
	dbmclose %TEMPFILE;
	$img-&gt;rectangle($x0, $y0, ($x0 + ($del * $xlen)), ($y0 + ($del * $ylen)), $gray);
}

 
sub print_triangle ($$$$$$$$$){

	my ($img, $x0, $x1, $y0, $y1, $black, $gray, $xlen, $dotfile) = @_;
	
	my $del = ($x1 - $x0) / $xlen;
	my %hash = ();
	my ($xd, $yd, $key, $value);
	my %TEMPFILE = ();
	dbmopen(%TEMPFILE, &quot;$dotfile&quot;, 0666) || die &quot;Can&#039;t open database $dotfile: $!&quot;;
	#avoid slurping again, pull values out one by one!
	while (($key,$value) = each %TEMPFILE){
		if ($key =~ m/[ACGT]+/){
			while ($value =~ m/x:(\d+)\t(.*)/){
				($hash{x}{$1}, $hash{y}{$1}, $value) = (1, 1, $2);	
			}
		}
		foreach $xd (keys(%{$hash{x}})){
			foreach $yd (keys(%{$hash{y}})){
					$img-&gt;setPixel(($x0 + (($del * ($xd + $yd)) * 0.5)), ($y1 - (($del * sqrt(($yd - $xd) * ($yd - $xd))) * 0.5)), $black);
			}
		}
		%hash = ();
	}
	dbmclose %TEMPFILE;
	$img-&gt;line($x0, $y1, $x1, $y1, $gray);
	$img-&gt;line($x0, $y1, (($x0 + $x1) * 0.5), ($y1 - (($x1 - $x0) * 0.5)), $gray);
	$img-&gt;line((($x0 + $x1) * 0.5), ($y1 - (($x1 - $x0) * 0.5)), $x1, $y1, $gray);
		
}

sub print_png ($$) {
    my ($img, $outfile) = @_;
    if ($outfile) {
	open(OUT, &quot;&gt;$outfile&quot;)
	    || die &quot;Cannot write $outfile: $!\n&quot;;
	print OUT $img-&gt;png;
	close OUT;
    } else {
	print $img-&gt;png;
    }
}

sub revcomp ($){
	my $f = shift(@_);
	my $r = reverse($f);
	$r =~ tr/GATC/CTAG/;
	return $r;
}</code>]]></description>
	<dc:creator>Abhimanyu Singh</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/30092/perl-script-to-calculate-n50</guid>
	<pubDate>Fri, 09 Dec 2016 04:14:04 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/30092/perl-script-to-calculate-n50</link>
	<title><![CDATA[Perl script to calculate N50]]></title>
	<description><![CDATA[<code>#! /usr/local/bin/perl5.8.3 -w

###
### Script Name : calcN50.pl
### Description : This script calculates the N50 of a collection of sequences in a fasta file
### Input       : A fasta sequence file and the minimum length of sequence to consider it for the N50 calculation
### Output      : None.  The N50 value as well as the number of sequences &gt;= this value is sent to STDOUT
###

use strict;
use Getopt::Long;
use Bio::SeqIO;

my $fasta_file;
my $filter_length;
GetOptions(&quot;fasta_file=s&quot; =&gt; \$fasta_file, &quot;length_filter=i&quot; =&gt; \$filter_length);
die &quot;Usage: $0 [options]
\t\t-f /path/to/fasta/file [Required]
\t\t-l filter seq less than length (0 if no filter is to be done)\n\n&quot; if !$fasta_file || !defined($filter_length) || $filter_length !~ /\d+/;

###
### Get the length of each sequence:
###
my $in = Bio::SeqIO-&gt;new(-file =&gt; $fasta_file, -format =&gt; &#039;fasta&#039;);
my @seq_lengths = ();
while (my $seq_obj = $in-&gt;next_seq){
	next if length($seq_obj-&gt;seq) &lt; $filter_length;
	push @seq_lengths, length($seq_obj-&gt;seq);
}



###
### Determine the N50:
###
my @vals;
my $sum = 0;
for my $val (@seq_lengths){
    chomp $val;
    $sum += $val;
    push(@vals, $val);
}

my @sorted = sort { $a &lt;=&gt; $b } @vals;

my $runningSum = 0;
my $N50 = 0;
foreach my $v (@sorted)
{
    $runningSum += $v;
    if($runningSum &gt;= ($sum / 2))
    {
	$N50 = $v;
	last;
    }
}


###
### Determine the number of sequences &gt;= than the N50 in length:
###
my $count = 0;
foreach my $v (@sorted)
{
    if($v &gt;= $N50)
    {
	$count++;
    }
}


printf(&quot;N50: $N50 Count &gt;= N50: $count\n&quot;);</code>]]></description>
	<dc:creator>Poonam Mahapatra</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/30033/perl-script-to-insert-sequence-in-contig</guid>
	<pubDate>Mon, 05 Dec 2016 00:34:49 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/30033/perl-script-to-insert-sequence-in-contig</link>
	<title><![CDATA[Perl script to insert sequence in contig !!]]></title>
	<description><![CDATA[<code># sub signature:
#insertSEQintoCONTIGatLOC( SEQ , CONTIG , LOC ) ;

sub insertSEQintoCONTIGatLOC{ 
	my ( $SEQ , $CONTIG , $LOC ) = @_;
	substr( $CONTIG , $LOC , -length($CONTIG) ) = $SEQ ;
	return $CONTIG; 
}

$s = &quot;ATATGATGATAGATGATAGTAGATAGATAGATAGATAGATAG&quot;;
print &quot;s = $s \n&quot;;
print &#039;insert     = &#039;.($s = insertSEQintoCONTIGatLOC( &quot;CCCC &quot;, $s , 26 )).&quot;\n&quot;;
print &quot;    (now, s =  &#039;$s&#039; ) \n&quot;;

# OUTPUT:
# s = ATATGATGATAGATGATAGTAGATAGATAGATAGATAGATAG
# insert     = &#039;CCCC &#039;
#     (now, s =  ATATGATGATAGATGATAGTAGATAGCCCCATAGATAGATAGATAG&#039; )&quot;;</code>]]></description>
	<dc:creator>Jit</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/28429/blast-script-to-index-and-extract-sequence</guid>
	<pubDate>Thu, 14 Jul 2016 09:52:17 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/28429/blast-script-to-index-and-extract-sequence</link>
	<title><![CDATA[Blast script to index and extract sequence !!]]></title>
	<description><![CDATA[<code># look at the file
$ head EC4115.fa 
&gt;NC_011353.1 Escherichia coli O157:H7 str. EC4115 chromosome, complete genome.
AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTCTC
TGACAGCAGCTTCTGAACTGGTTACCTGCCGTGAGTAAATTAAAATTTTATTGACTTAGG
TCACTAAATACTTTAACCAATATAGGCATAGCGCACAGACAGATAAAAATTACAGAGTAC

# generate the blast database
$ makeblastdb -dbtype nucl -out EC -in EC4115.fa -parse_seqids

# retreive an entry by id
$ blastdbcmd -db EC -entry &#039;NC_011353.1&#039; | head
&gt;lcl|NC_011353.1 Escherichia coli O157:H7 str. EC4115 chromosome, complete genome
AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTCTCTGACAGCAGCTTCTGAACTG
GTTACCTGCCGTGAGTAAATTAAAATTTTATTGACTTAGGTCACTAAATACTTTAACCAATATAGGCATAGCGCACAGAC
....

# query the blast database by id and coordinates
$ blastdbcmd -db EC -range 100-105 -entry &#039;NC_011353.1&#039;
&gt;lcl|NC_011353.1:100-105 Escherichia coli O157:H7 str. EC4115 chromosome, complete genome
TTAAAA</code>]]></description>
	<dc:creator>Shruti Paniwala</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/28282/perl-script-introduces-control-structures-arrays-and-hashes</guid>
	<pubDate>Mon, 04 Jul 2016 08:42:47 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/28282/perl-script-introduces-control-structures-arrays-and-hashes</link>
	<title><![CDATA[Perl script introduces control structures, arrays and hashes.]]></title>
	<description><![CDATA[<code>#!/usr/bin/env perl

use strict;
use warnings;

my @first_array = (&#039;DNA&#039;, &#039;ATGCGTGC&#039;, 5, &#039;RNA&#039;, &#039;AUGC&#039;);
print $first_array[0], &quot;\n\n&quot;;

# Scalar gives actual size of an array

my $size_of_array = scalar(@first_array);
my $another_way_of_getting_size_of_array = @first_array; # implicit way
print &quot;Scalar of array: $size_of_array\n\n&quot;;
print &quot;Perl&#039;s index size of array: $#first_array\n\n&quot;;
print &quot;Another way of getting size: $another_way_of_getting_size_of_array\n\n&quot;;

# Control Loop: for

for (my $i=0; $i&lt;=$#first_array; $i++) {
    print &quot;Perl&#039;s array index: $i\n\n&quot;;
    print &quot;$first_array[$i] \n\n&quot;; 
}

my %sequence = (&#039;DNA&#039; =&gt; &#039;ATCGATGCT&#039;,
                &#039;RNA&#039; =&gt; &#039;AUGC&#039;,
                &#039;Number of seqs&#039; =&gt; 2
                );

print $sequence{&#039;DNA&#039;}, &quot;\n&quot;;
# Control Loop: foreach

foreach my $key (sort (keys %sequence)) {
    print &quot;Key of hash is $key\tValue of hash is $sequence{$key}\n\n&quot;;
}</code>]]></description>
	<dc:creator>Neel</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/28193/perl-subroutine-to-read-and-write-files</guid>
	<pubDate>Thu, 30 Jun 2016 16:48:55 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/28193/perl-subroutine-to-read-and-write-files</link>
	<title><![CDATA[Perl subroutine to read and write files]]></title>
	<description><![CDATA[<code># Input output (InOut) the file
# usage:
# @array  = InOut(&#039;read&#039;,$file)
# $string = InOut(&#039;read&#039;,$file)
# InOut(&#039;write&#039;,$file,\$string)
# InOut(&#039;write&#039;,$file,\@array)
#$string = &quot;YO!&quot;;
#InOut(&#039;write&#039;,&#039;file.txt&#039;,\$string);

sub InOut {
my($bit,$file,$data) = @_;

if($bit eq &#039;read&#039;){
    open InOut,&quot;&lt; $file&quot; or die &quot;Cannot open $file for input: $!\n&quot;;
    my @file = &lt;InOut&gt;;
    close InOut;
    return wantarray ? @file :  join &#039;&#039;, @file;
    }
if($bit eq &#039;write&#039;){
    open  InOut,&quot;&gt; $file&quot; or die &quot;Cannot open $file for output: $!\n&quot;;
    print InOut  ref $data eq &#039;ARRAY&#039; ? @$data : ref $data eq &quot;SCALAR&quot;? $$data : &#039;&#039;;
    close InOut;
    }
}</code>]]></description>
	<dc:creator>Neel</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/28048/calculate-confidence-interval-for-multiple-columns-in-a-matrix-table-using-r-function-ci-normal-and-ci-tdist</guid>
	<pubDate>Fri, 24 Jun 2016 18:01:04 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/28048/calculate-confidence-interval-for-multiple-columns-in-a-matrix-table-using-r-function-ci-normal-and-ci-tdist</link>
	<title><![CDATA[Calculate confidence interval for multiple columns in a matrix (table) using R function CI_normal and CI_tdist]]></title>
	<description><![CDATA[<code>#USAGE: CI_normal(matrix[,c(x:y)],97.5) - multiple column from a normal distribution
#USAGE: CI_tdist(matrix[,c(x:y)],97.5) - multiple column from a t distribution
#USAGE: CI_normal(matrix[,x],97.5) - single column from a normal distribution
#USAGE: CI_tdist(matrix[,x],97.5) - single column from a t distribution
#Created and updated by Santhilal Subhash on 2016/06/07 
CI_normal &lt;- function(li,stat)
{
	cat(paste0(&quot;CI&quot;,&quot;\t&quot;,&quot;column&quot;,&quot;\t&quot;,&quot;Lower.limit&quot;,&quot;\t&quot;,&quot;Upper.limit&quot;,&quot;\n&quot;))
	if(length(colnames(li))&gt;1)
	{
		for(i in 1:length(colnames(li)))
		{
			sample &lt;- colnames(li)
			error &lt;- qnorm(stat/100)*sd(li[,i])/sqrt(length(li[,i]))
			left &lt;- mean(li[,i])-error
			right &lt;- mean(li[,i])+error
			cat(paste0(stat,&quot;% norm dist&quot;,&quot;\t&quot;,sample[i],&quot;\t&quot;,left,&quot;\t&quot;,right,&quot;\n&quot;))

		}
	}
	else{
		error &lt;- qnorm(stat/100)*sd(li)/sqrt(length(li))
		left &lt;- mean(li)-error
		right &lt;- mean(li)+error
		cat(paste0(stat,&quot;% norm dist&quot;,&quot;\tNA&quot;,&quot;\t&quot;,left,&quot;\t&quot;,right,&quot;\n&quot;))

	}

}
CI_tdist &lt;- function(li,stat)
{
	cat(paste0(&quot;CI&quot;,&quot;\t&quot;,&quot;column&quot;,&quot;\t&quot;,&quot;Lower.limit&quot;,&quot;\t&quot;,&quot;Upper.limit&quot;,&quot;\n&quot;))
	if(length(colnames(li))&gt;1)
	{
		for(i in 1:length(colnames(li)))
		{
			sample &lt;- colnames(li)
			error &lt;- qt(stat/100,df=length(li[,i])-1)*sd(li[,i])/sqrt(length(li[,i]))
			left &lt;- mean(li[,i])-error
			right &lt;- mean(li[,i])+error
			cat(paste0(stat,&quot;% t-dist&quot;,&quot;\t&quot;,sample[i],&quot;\t&quot;,left,&quot;\t&quot;,right,&quot;\n&quot;))

		}
	}
	else{

		error &lt;- qt(stat/100,df=length(li)-1)*sd(li)/sqrt(length(li))
		left &lt;- mean(li)-error
		right &lt;- mean(li)+error
		cat(paste0(stat,&quot;% t-dist&quot;,&quot;\tNA&quot;,&quot;\t&quot;,left,&quot;\t&quot;,right,&quot;\n&quot;))

	}

}</code>]]></description>
	<dc:creator>EagleEye</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/28043/rpkm-normalization-perl</guid>
	<pubDate>Fri, 24 Jun 2016 17:53:09 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/28043/rpkm-normalization-perl</link>
	<title><![CDATA[RPKM normalization - Perl]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
#use strict;
#use warnings;
#Author: Santhilal Subhash
#Contact: santhilal.subhash@gu.se
#RPKM for RNAseq V1.3
#USAGE for sample input provided: perl rpkm_script_beta.pl sample_count_test.count 2:9 15 &gt; sample_count_test.rpkm
#USAGE: perl rpkm_script_beta.pl input_count_file.txt ActualColumnStart:ActualColumnEnd ColumnGeneLength &gt; results.rpkm
open $fh1, &#039;&lt;&#039;, $ARGV[0] or die $!;
open $fh2, &#039;&lt;&#039;, $ARGV[0] or die $!;
$total = 0;
$count = 0;
$cols=$ARGV[1];
$len_col=$ARGV[2];
while (&lt;$fh1&gt;) 
{
	@array=split(&quot;\t&quot;);
	($cstart,$cend)=split(&quot;:&quot;,$cols);
	for($i=$cstart-1;$i&lt;=$cend-1;$i++)
	{
		$libarray[$i] += $array[$i];
	}
}

while (&lt;$fh2&gt;) 
{
	$next = &lt;&gt;;
	if ($next =~ /^#/) 
	{
		$header=$next;
		$header =~ s/#//;
		print &quot;$header&quot;;
	}
	if ($next !~ /^#/) 
	{

 		@array=split(&quot;\t&quot;);
  		($cstart,$cend)=split(&quot;:&quot;,$cols);
  		for($i=$cstart-1;$i&lt;=$cend-1;$i++)

		{
			if($array[$i]!=0)
			{
				$array_rpkm[$i]=((1000000000*$array[$i])/($libarray[$i]*$array[$len_col-1]));
			}
			else
			{
				$array_rpkm[$i]=0;
			}
		}
			local $&quot; = &quot;\t&quot;;
				
		print &quot;$array[$cstart-2]@array_rpkm\t@array[$cend..$#array]&quot;;
	}
}</code>]]></description>
	<dc:creator>EagleEye</dc:creator>
</item>

</channel>
</rss>