Skip to content

Commit

Permalink
Parameter #3: subset
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyacheslav Brover committed Aug 12, 2024
1 parent bd54a96 commit a895521
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions genetics/dna_closest.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
#!/bin/bash --noprofile
THIS=`dirname $0`
source $THIS/../bash_common.sh
if [ $# -ne 2 ]; then
if [ $# -ne 3 ]; then
echo "Return: top 100 BLASTN hits in top strand"
echo "#1; query DNA sequence"
echo "#2: subject DNA BLAST database"
echo "#3: subset of sequence id's or ''"
exit 1
fi
QUERY=$1
DB=$2
SUBSET=$3


TMP=`mktemp`
TMP=$( mktemp )
#comment $TMP


blastn -db $DB -query $QUERY -strand plus -task blastn -num_threads 5 -outfmt '6 sseqid nident' | sort -k 2 -n -r | cut -f 1 > $TMP
head -100 $TMP | sort -u
blastn -db $DB -query $QUERY -strand plus -task blastn -num_threads 5 -outfmt '6 sseqid nident' | sort -u > $TMP

# $TMP -> $TMP.inter
if [ $SUBSET ]; then
sort -cu $SUBSET
join -1 1 -2 1 $TMP $SUBSET | tr ' ' '\t' > $TMP.inter
else
mv $TMP $TMP.inter
fi

sort -k2nr $TMP.inter | cut -f 1 > $TMP.sorted
head -100 $TMP.sorted


rm $TMP*

0 comments on commit a895521

Please sign in to comment.