<?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: Owner]]></title>
	<link>https://bioinformaticsonline.com/snippets/owner/anjana?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/owner/anjana?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27299/retrieve-ncbi-genbank-records-with-a-range-of-accession-numbers</guid>
	<pubDate>Wed, 11 May 2016 11:02:40 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27299/retrieve-ncbi-genbank-records-with-a-range-of-accession-numbers</link>
	<title><![CDATA[Retrieve NCBI GenBank records with a range of accession numbers]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl

#FILE: ncbi_search.pl
#AUTH: Paul Stothard (paul.stothard@gmail.com)

use warnings;
use strict;
use Getopt::Long;
use LWP::Simple;
use URI::Escape;

use LWP::UserAgent;
use HTTP::Request::Common;

my %param = (
    query      =&gt; undef,
    outputFile =&gt; undef,
    database   =&gt; undef,
    returnType =&gt; undef,
    maxRecords =&gt; undef,
    format     =&gt; undef,
    verbose    =&gt; undef,
    url        =&gt; &#039;http://www.ncbi.nlm.nih.gov/entrez/eutils&#039;,
    retries    =&gt; 0,
    maxRetries =&gt; 5,
    help       =&gt; undef
);

Getopt::Long::Configure(&#039;bundling&#039;);
GetOptions(
    &#039;q|query=s&#039;       =&gt; \$param{query},
    &#039;o|output_file=s&#039; =&gt; \$param{outputFile},
    &#039;d|database=s&#039;    =&gt; \$param{database},
    &#039;r|return_type=s&#039; =&gt; \$param{returnType},
    &#039;m|max_records=i&#039; =&gt; \$param{maxRecords},
    &#039;verbose|v&#039;       =&gt; \$param{verbose},
    &#039;h|help&#039;          =&gt; \$param{help}
);

if ( defined( $param{help} ) ) {
    print_usage();
    exit(0);
}

if (   !( defined( $param{query} ) )
    or !( defined( $param{outputFile} ) )
    or !( defined( $param{database} ) )
    or !( defined( $param{returnType} ) ) )
{
    print_usage();
    exit(1);
}

$param{returnType} = lc( $param{returnType} );

$param{query} = uri_escape( $param{query} );

_doSearch(%param);

sub _doSearch {
    my %param = @_;

    my $esearch = &quot;$param{url}/esearch.fcgi?db=$param{database}&quot;
        . &quot;&amp;retmax=1&amp;usehistory=y&amp;term=$param{query}&quot;;
    my $esearch_result = get($esearch);

    while (
        ( !defined($esearch_result) )
        || (!(  $esearch_result
                =~ m/&lt;Count&gt;(\d+)&lt;\/Count&gt;.*&lt;QueryKey&gt;(\d+)&lt;\/QueryKey&gt;.*&lt;WebEnv&gt;(\S+)&lt;\/WebEnv&gt;/s
            )
        )
        )
    {
        if ($esearch_result =~ m/&lt;ERROR&gt;(.*)&lt;\/ERROR&gt;/is) {
            die(&quot;ESearch returned an error: $1&quot;);
        }
        message( $param{verbose},
            &quot;ESearch results could not be parsed. Resubmitting query.\n&quot; );
        sleep(10);
        if ( $param{retries} &gt;= $param{maxRetries} ) {
            die(&quot;Too many failures--giving up search.&quot;);
        }

        $esearch_result = get($esearch);
        $param{retries}++;
    }

    $param{retries} = 0;

    $esearch_result
        =~ m/&lt;Count&gt;(\d+)&lt;\/Count&gt;.*&lt;QueryKey&gt;(\d+)&lt;\/QueryKey&gt;.*&lt;WebEnv&gt;(\S+)&lt;\/WebEnv&gt;/s;

    my $count     = $1;
    my $query_key = $2;
    my $web_env   = $3;

    if ( defined( $param{maxRecords} ) ) {
        if ( $count &gt; $param{maxRecords} ) {
            message( $param{verbose},
                &quot;Retrieving $param{maxRecords} records out of $count available records.\n&quot;
            );
            $count = $param{maxRecords};
        }
        else {
            message( $param{verbose},
                &quot;Retrieving $count records out of $count available records.\n&quot;
            );
        }
    }
    else {
        message( $param{verbose},
            &quot;Retrieving $count records out of $count available records.\n&quot; );
    }

    my $retmax = 500;
    if ( $retmax &gt; $count ) {
        $retmax = $count;
    }

    open( my $OUTFILE, &quot;&gt;&quot; . $param{outputFile} )
        or die(&quot;Error: Cannot open $param{outputFile} : $!&quot;);

    for (
        my $retstart = 0;
        $retstart &lt; $count;
        $retstart = $retstart + $retmax
        )
    {
        message( $param{verbose},
                  &quot;Downloading records &quot;
                . ( $retstart + 1 ) . &quot; to &quot;
                . ( $retstart + $retmax )
                . &quot;\n&quot; );
        my $efetch
            = &quot;$param{url}/efetch.fcgi?rettype=$param{returnType}&amp;retmode=text&amp;retstart=$retstart&amp;retmax=$retmax&amp;db=$param{database}&amp;query_key=$query_key&amp;WebEnv=$web_env&quot;;
        my $efetch_result = get($efetch);

        while ( !defined($efetch_result) ) {
            message( $param{verbose},
                &quot;EFetch results could not be parsed. Resubmitting query.\n&quot; );
            sleep(10);
            if ( $param{retries} &gt;= $param{maxRetries} ) {
                die(&quot;Too many failures--giving up search.&quot;);
            }

            $efetch_result = get($efetch);
            $param{retries}++;
        }

        print( $OUTFILE $efetch_result );

        unless (
            ( defined( $param{maxRecords} ) &amp;&amp; ( $param{maxRecords} == 1 ) ) )
        {
            sleep(3);
        }
    }

    close($OUTFILE) or die(&quot;Error: Cannot close $param{outputFile} file: $!&quot;);
}

sub message {
    my $verbose = shift;
    my $message = shift;
    if ($verbose) {
        print $message;
    }
}

sub print_usage {
    print &lt;&lt;BLOCK;
USAGE:
   perl ncbi_search.pl -q STRING -o FILE -d STRING -r STRING [Options]

DESCRIPTION:
   Uses NCBI&#039;s eSearch to download collections of sequences.

REQUIRED ARGUMENTS:
   -q, --query [STRING]
      Raw query text.
   -o, --output [FILE]
      Output file to create.
   -d, --database [STRING]
      Name of the NCBI database to search, such as &#039;nucleotide&#039;, &#039;protein&#039;,
      or &#039;gene&#039;.
   -r, --return_type [STRING]
      The type of information requested. For sequences &#039;fasta&#039; is often used.
      The accepted formats vary depending on the database being queried.
   -m, --max_records [INTEGER]
      The maximum number of records to return (default is to return all matches
      satisfying the query).
   -v, --verbose
      Provide progress messages.
   -h, --help
      Show this message.

EXAMPLE:
   perl ncbi_search.pl -q &#039;dysphagia AND homo sapiens[ORGN]&#039; \\
     -o results.txt -d pubmed -r uilist -m 100

BLOCK
}</code>]]></description>
	<dc:creator>Anjana</dc:creator>
</item>
<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>

</channel>
</rss>