-
Notifications
You must be signed in to change notification settings - Fork 6
/
extractfasta.sh
executable file
·22 lines (20 loc) · 1.13 KB
/
extractfasta.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /bin/bash
#######################################################################################
### extractfasta.sh - V1 - Clement Goubert (2020) - [email protected] ###
### ------------------------------------------------------------------------------- ###
### This script extract a fasta sequence based on header or list of headers ###
### USAGE: ./extractfasta.sh $1<H/L: H=header given; L=list given> ###
### $2<Header [string] / List of headers [file]> $3<Consensus.file.fasta> ###
### query: path to query (fasta file) ###
### db: path to blast db (blast formated nucleotide database) ###
#######################################################################################
# USAGE:
# ./extractfasta.sh $1<H/L: H=header given; L=list given> $2<Header [string] / List of headers [file]> $3<Consensus.file.fasta>
if [ $1 == "H" ]
then
#echo "H!"
perl -ne 'if(/^>(\S+)/){$c=$i{$1}}$c?print:chomp;$i{$_}=1 if @ARGV' <(echo "$2") $3
else
#echo "L!"
perl -ne 'if(/^>(\S+)/){$c=$i{$1}}$c?print:chomp;$i{$_}=1 if @ARGV' $2 $3
fi