<?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: BASH script for SelfBLAST a genome]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/30686/bash-script-for-selfblast-a-genome?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/30686/bash-script-for-selfblast-a-genome?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/30686/bash-script-for-selfblast-a-genome</guid>
	<pubDate>Mon, 30 Jan 2017 09:31:33 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/30686/bash-script-for-selfblast-a-genome</link>
	<title><![CDATA[BASH script for SelfBLAST a genome]]></title>
	<description><![CDATA[<code>#!/bin/bash

#self BLAST a genome -- Expecting you have blast and samtools installed in your system
#Author: Jitendra Narayan
#USAGE: ./selfBlast.sh extract &lt;chrName&gt;
#USAGE: ./selfBlast.sh all

#Common settings 
FASTAFILE=MergedContigs.fasta
MYDB=myDB
OUTFILE=seeRES
THREAD=20
SEQ=&quot;&quot;

echo &quot;User $USER provided $# arguments, Detail of the arguments: $@&quot;

if [ -f $MYDB.nhr ]
then
  echo &quot;BLAST database for MergedContigs.fasta genome exists&quot;
else
  echo &quot;Thanks for testing this script $USER; Me creating creating blastDB named $MYDB for you&quot;;
  makeblastdb -in $FASTAFILE -parse_seqids -dbtype nucl -out $MYDB
fi

if [ $1 = &quot;extract&quot; ]
then
  echo &quot;Extracting the sequence $2 for you from $FASTAFILE -- MAKE SURE U HAVE ADDED CORRECT NAME&quot;
  samtools faidx MergedContigs.fasta
  samtools faidx MergedContigs.fasta $2 &gt; $2.fa
  SEQ=$2.fa
elif [ $1 = &quot;all&quot; ]
then
  echo &quot;You want entire sequence to blast&quot;
  SEQ=$FASTAFILE
else
  echo &quot;Something went wrong $USER - Contact jitendra&quot;
fi

echo &quot;Doing alignments -- BLASting&quot;;
blastn -task megablast -query $SEQ -db $MYDB -evalue 1e-5 -num_threads $THREAD -max_target_seqs 1 -outfmt &#039;6 qseqid staxid qstart qend sseqid sstart send evalue length frames qcovs&#039; -out $OUTFILE;

echo &quot;DONE successfully :)&quot;</code>]]></description>
	<dc:creator>Jit</dc:creator>
</item>

</channel>
</rss>