<?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=420</link>
	<atom:link href="https://bioinformaticsonline.com/snippets?offset=420" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27296/perl-script-to-count-the-number-of-adenine-thymine-guanine-and-cytosine-in-your-dna-sequence</guid>
	<pubDate>Wed, 11 May 2016 10:34:44 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27296/perl-script-to-count-the-number-of-adenine-thymine-guanine-and-cytosine-in-your-dna-sequence</link>
	<title><![CDATA[Perl script to count the number of Adenine, Thymine, Guanine and Cytosine in your DNA Sequence]]></title>
	<description><![CDATA[<code>#!/usr/local/bin/perl -w

# While executing this script it asks for the file name of the DNA sequence. If the sequence file is not available in the same directory of this script, enter the name of the file along with the path.  
In windows:  c:\dnafile.txt, 
In Linux: /home/user/sequence/dnafile.txt

print &quot;ENTER THE FILENAME OF THE DNA SEQUENCE:= &quot;;
$dna_filename = &lt;STDIN&gt;;
chomp $dna_filename;
unless ( open(DNAFILE, $dna_filename) ) 
{
	print &quot;Sorry the file does not exist!!! \n&quot;;
	print &quot;Cannot open file \&quot;$dna_filename\&quot;\n&quot;;
	die;
}
@DNA = &lt;DNAFILE&gt;;
close DNAFILE;
$DNA = join( &#039;&#039;, @DNA);
print &quot; \n The original DNA file is:\n  $DNA \n&quot;;
$DNA =~ s/\s//g;
@DNA = split( &#039;&#039;, $DNA );
$count_of_A = 0;
$count_of_C = 0;
$count_of_G = 0;
$count_of_T = 0;
$errors     = 0;
foreach $base (@DNA) {

    if     ( $base eq  &#039;a&#039; ) {
        ++$count_of_A;
    } elsif ( $base eq &#039;c&#039; ) {
        ++$count_of_C;
    } elsif ( $base eq &#039;g&#039; ) {
        ++$count_of_G;
    } elsif ( $base eq &#039;t&#039; ) {
        ++$count_of_T;
    }
        elsif ( $base eq &#039;T&#039; ) {
        ++$count_of_T; }

        elsif ( $base eq &#039;C&#039; ) {
        ++$count_of_C; }
        elsif ( $base eq &#039;A&#039; ) {
        ++$count_of_A; }
        elsif ( $base eq &#039;G&#039; ) {
        ++$count_of_G; }

        else {
        print &quot;Error - Unknown base: $base\n&quot;;
        ++$errors;
    }
}
print &quot;Adenine = $count_of_A\n&quot;;
print &quot;Cytosine = $count_of_C\n&quot;;
print &quot;Guanine = $count_of_G\n&quot;;
print &quot;Thymine = $count_of_T\n&quot;;

if ($errors) {
        print &quot;There were $errors unrecognized bases.\n&quot;;
}</code>]]></description>
	<dc:creator>Anjana</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27295/perl-script-to-mutate-a-dna-sequence</guid>
	<pubDate>Wed, 11 May 2016 10:27:58 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27295/perl-script-to-mutate-a-dna-sequence</link>
	<title><![CDATA[Perl script to Mutate a DNA Sequence]]></title>
	<description><![CDATA[<code>#!/usr/local/bin/perl -w

# This script randomly mutates the DNA sequence and generates 10 successive mutation results.
# While executing this script it asks for the file name of the DNA sequence.
# If the DNA sequence file is not in the same directory of this script, enter the file name with its full path.
# Example:
# In windows:  c:\rnafile.txt
# In Linux  : /home/user/sequence/rnafile.txt

use File::Path;

print &quot;ENTER THE FILENAME OF THE DNA SEQUENCE:= &quot;;
$dnafilename = &lt;STDIN&gt;;
chomp $dnafilename;
unless ( open(DNAFILE, $dnafilename) ) 
{
    print &quot;Cannot open file \&quot;$dnafilename\&quot;\n\n&quot;;
    goto h;
}
my $DNA = &lt;DNAFILE&gt;;
close DNAFILE;

my $i;
my $mutant;
$mutant = mutate($DNA);
print &quot;Mutate DNA\n\n&quot;;

print &quot;HERE ARE THE 10 SUCCESSIVE MUTATIONS:\n\n&quot;;
for ($i=0 ; $i &lt; 10 ; ++$i)
  {
    $mutant = mutate($mutant);
    print &quot;$mutant\n&quot;;
        print WRITE &quot;$mutant\n&quot;;
  }

sub mutate
  {
        my($dna) = @_;
        my($position) = randomposition($dna);
        my $current_base = substr($dna, $position, 1);
        my $newbase;
    do
  {
        $newbase = randomnucleotide();
  }
        until ($newbase ne $current_base);
        substr($dna,$position,1,$newbase);
        return $dna;
  }
sub randomposition
  {
        my($string) = @_;
        return int rand length $string;
  }
sub randomelement
  {
    my(@array) = @_;
    return $array[rand @array];
  }
sub randomnucleotide
  {
    my(@nucleotides) = (&#039;A&#039;, &#039;C&#039;, &#039;G&#039;, &#039;T&#039;);
    return randomelement(@nucleotides);
  }</code>]]></description>
	<dc:creator>Anjana</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27294/check-all-seqs-in-a-folder</guid>
	<pubDate>Wed, 11 May 2016 10:16:47 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27294/check-all-seqs-in-a-folder</link>
	<title><![CDATA[Check all seqs in a folder]]></title>
	<description><![CDATA[<code>#!/usr/local/bin/perl -w

# Can be easily modified to run any command on every sequence in a folder
# Directory of sequences
$myDir = &quot;/home/anjana/seqs&quot;;

# Output directory (relative to $myDir or full path)
$outputDir = &quot;OutDir&quot;;

# Path to pattern file
$patFile = &quot;/home/anjana/patterns/polyA.pat&quot;;

# Go to sequence directory and open it (i.e, read contents)
chdir($myDir) || die &quot;Cannot change to $myDir: $!&quot;;      # Go to $myDir
opendir(DIR, &quot;.&quot;) || die &quot;Cannot open .: $!&quot;;      # Open $myDir

foreach $seqFile (sort readdir(DIR))
{
    if ($seqFile =~ /\.fa$/)      # if file ends in .fa
    {
        print &quot;Processing $seqFile\n&quot;;
        $outFile = $seqFile;         # Create $outFile name
        $outFile =~ s/\.fa/\.polyA\.out/;      # s/old/new/; 

        #User can process these files as per their need
        print &quot;$patFile \t$seqFile \t $outputDir/$outFile\n&quot;;
     }
}</code>]]></description>
	<dc:creator>Anjana</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27293/bioperl-to-convert-between-sequence-formats-from-fasta-to-genbank</guid>
	<pubDate>Wed, 11 May 2016 09:49:04 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27293/bioperl-to-convert-between-sequence-formats-from-fasta-to-genbank</link>
	<title><![CDATA[BioPerl to convert between sequence formats from Fasta to Genbank]]></title>
	<description><![CDATA[<code>#!/usr/local/bin/perl -w

# Sequence formats to choose: Fasta, EMBL. GenBank, Swissprot, PIR and GCG

use Bio::SeqIO;

$inFile = &quot;BRCA2.fa&quot;;

$in  = Bio::SeqIO-&gt;newFh(&#039;-file&#039; =&gt; &quot;$inFile&quot; ,
                           &#039;-format&#039; =&gt; &#039;Fasta&#039;);
$out = Bio::SeqIO-&gt;newFh(&#039;-format&#039; =&gt; &#039;Genbank&#039;);
print $out $_ while &lt;$in&gt;;</code>]]></description>
	<dc:creator>Anjana</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27270/parse-a-genbank-file-using-regular-expressions</guid>
	<pubDate>Tue, 10 May 2016 11:56:26 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27270/parse-a-genbank-file-using-regular-expressions</link>
	<title><![CDATA[Parse a genbank file using regular expressions]]></title>
	<description><![CDATA[<code>#! /usr/local/bin/perl -w

$genbank = &quot;genbank_file.txt&quot;;

open (GENBANK, $genbank) || die &quot;cannot open $gb_report for reading: $!&quot;;

# Flag for multiline translation; 1 means translation &quot;in progress&quot;  
$trans = 0;

while (&lt;GENBANK&gt;)
{
   if (/(LOCUS\s*)(\w*)(.*)/) { 
       print &quot;Locus: $2\n&quot;; 
   }
   elsif (/(VERSION.*GI:)(\d*)/) { 
      print &quot;GI: $2\n&quot;; 
   }
   elsif (/(DEFINITION\s*)(.*)(\.)/) {
      print &quot;Sequence name: $2\n&quot;;
   }
   elsif (/(ORGANISM\s*)(.*)/) {
      print &quot;Organism: $2\n&quot;;
   }
   elsif(/(gene)(\s*)(\d*)(\.\.)(\d*)/) {
      print &quot;Gene length: $5\n&quot;;
   }
   elsif (/(CDS\s*)(\d*)(\.\.)(\d*)/)  {
   # ex: CDS             357..1541
      $cds_start = $2;
      $cds_end = $4;
      print &quot;CDS: $cds_start - $cds_end\n&quot;;
   }
   elsif (/(\/translation=&quot;)(.*)/)  {  # protein product begins
      print &quot;Translation: &quot;;
      $protein = $2;
      $trans = 1;
   }
   elsif ($trans)  {   # translation still going on
      if (!/&quot;/)  {  # no terminal quote; translation continues
         $protein .= $_;
      }
      elsif (/(.*)(&quot;)/)  {  # terminal quote; end of translation
         $protein .= $1;
         $protein =~ s/\s*//g;
         print &quot;$protein\n&quot;;
         $trans = 0;
      }
      else  {
         print &quot;Problems: end of translation product not found.\n&quot;;
      }
   }
   else  {
      # Skip this data
   }
}</code>]]></description>
	<dc:creator>Nishi Singh</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27269/check-if-your-coputer-ready-to-use-bioperl</guid>
	<pubDate>Tue, 10 May 2016 11:48:50 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27269/check-if-your-coputer-ready-to-use-bioperl</link>
	<title><![CDATA[Check if your coputer ready to use BioPerl]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
use strict;
use warnings;

#bioperl example code
use strict;
use warnings;

#make the bioperl module (class) accessible to your program
use Bio::Seq;

print&quot;ok - ready to use Bio::Seq&quot;;</code>]]></description>
	<dc:creator>Nishi Singh</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27268/read-lines-from-input-file-%E2%80%93-print-lines-that-match-a-regular-expression</guid>
	<pubDate>Tue, 10 May 2016 11:46:19 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27268/read-lines-from-input-file-%E2%80%93-print-lines-that-match-a-regular-expression</link>
	<title><![CDATA[Read lines from input file – print lines that match a regular expression]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
use strict;
use warnings;

my $line;

#read the line-by-line for each line ask if it matches the regex print it if it matches

while($line = &lt;DATA&gt;){
        chomp $line;
        if ($line =~ /^ATG?C*[ATCG]+?A{3,10}$/) {
                print &quot;$line\n&quot;;
        }
}

exit();

__DATA__
ATGCCCAA
ATGCCCAAAA
ATGCCCAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD</code>]]></description>
	<dc:creator>Nishi Singh</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27267/for-a-given-dna-sequence-find-its-rna-transcript-find-its-reverse-complement-and-check-if-the-reverse-complement-contains-a-start-codon</guid>
	<pubDate>Tue, 10 May 2016 11:42:30 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27267/for-a-given-dna-sequence-find-its-rna-transcript-find-its-reverse-complement-and-check-if-the-reverse-complement-contains-a-start-codon</link>
	<title><![CDATA[For a given DNA sequence find its RNA transcript, find its reverse complement and check if the reverse complement contains a start codon]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
use strict;
use warnings;

my $DNA = &quot;GATTACACAT&quot;;

#transcribe DNA to RNA - T changes to U
my $RNA = $DNA;
$RNA =~ s/T/U/g;
print &quot;RNA sequence is $RNA\n&quot;;

#find the reverse complement of $DNA using substitution operator
#first - reverse the sequence
my $rcDNA = reverse($DNA);

$rcDNA =~ s/T/A/g;
$rcDNA =~ s/A/T/g;
$rcDNA =~ s/G/C/g;
$rcDNA =~ s/C/G/g;

print &quot;Reverse complement of $DNA is $rcDNA\n&quot;; #did it work?

#find the reverse complement of $DNA using translation operator
#first - reverse the sequence
$rcDNA = reverse($DNA);
#then - complement the sequence
$rcDNA =~ tr/ACGT/TGCA/;
#then - print the reverse complement
print &quot;Reverse complement of $DNA is $rcDNA\n&quot;;

#look for a start codon in the reverse sequence
if($rcDNA =~ /ATG/){
	print &quot;Start codon found\n&quot;;
}
else{
	print &quot;Start codon not found\n&quot;;
}</code>]]></description>
	<dc:creator>Nishi Singh</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27266/count-the-frequency-of-base-g-in-a-given-dna-sequence</guid>
	<pubDate>Tue, 10 May 2016 11:38:32 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27266/count-the-frequency-of-base-g-in-a-given-dna-sequence</link>
	<title><![CDATA[Count the frequency of base G in a given DNA sequence]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
use strict;
use warnings;

my $DNA = &quot;GATTACACAT&quot;;

#initialize $countG and $currentPos
my $countG = 0;
my $currentPos = 0;

#calculate the length of $DNA
my $DNAlength = length($DNA);

#for each letter in the sequence check if it is the base G
#if &#039;yes&#039; increment $countG
while($currentPos &lt; $DNAlength){
	my $base = substr($DNA,$currentPos,1);
	if($base eq &quot;G&quot;){
		$countG++;
	}
	$currentPos++;
} #end of while loop

#print out the number of Gs
print &quot;There are $countG G bases\n&quot;;</code>]]></description>
	<dc:creator>Nishi Singh</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27265/concatenate-two-given-sequences-and-find-the-length-of-the-new-sequence-and-also-print-out-the-second-codon-of-the-sequence</guid>
	<pubDate>Tue, 10 May 2016 11:36:27 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27265/concatenate-two-given-sequences-and-find-the-length-of-the-new-sequence-and-also-print-out-the-second-codon-of-the-sequence</link>
	<title><![CDATA[Concatenate two given sequences, and find the length of the new sequence and also print out the second codon of the sequence]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
use strict;
use warnings;

#assign strings to variables
my $DNA = &quot;GATTACACAT&quot;;
my $polyA = &quot;AAAA&quot;;

#concatenate two strings
my $modifiedDNA = $DNA.$polyA;

#calculate the length of $modifiedDNA and
#print out the value of the variable and its length
my $DNAlength = length($modifiedDNA);
print &quot;Modified DNA: $modifiedDNA has length $DNAlength\n&quot;;

#extract the second codon in $modifiedDNA
my $codon = substr($modifiedDNA,3,3);
print &quot;Second codon is $codon\n&quot;;</code>]]></description>
	<dc:creator>Nishi Singh</dc:creator>
</item>

</channel>
</rss>