Debian Codegraph @

gbf2facds

raw
1 #!/bin/sh
2
3 # Public domain notice for all NCBI EDirect scripts is located at:
4 # https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice
5
6 # Converts GenBank flatfile to fasta_cds_na or fasta_cds_aa format
7
8 # efetch -db nuccore -id U54469 -format gb | gbf2facds -na
9 # efetch -db nuccore -id NC_019703.1 -format gb -seq_start 3890572 -seq_stop 3891654 | gbf2facds -aa
10
11 seqtype="transcription"
12 accnsfx="_cds_"
13
14 while [ $# -gt 0 ]
15 do
16 case "$1" in
17 nuc | -nuc | NUC | -NUC | na | -na | NA | -NA )
18 seqtype="transcription"
19 accnsfx="_cds_"
20 shift
21 ;;
22 prt | -prt | PRT | -PRT | aa | -aa | AA | -AA )
23 seqtype="translation"
24 accnsfx="_prot_"
25 shift
26 ;;
27 * )
28 exec >&2
29 echo "$0: Unrecognized argument $1"
30 exit 1
31 ;;
32 esac
33 done
34
35 gbf2info |
36 xtract -pattern GenBankInfo -ACCN accession \
37 -group feature -if feature_key -equals CDS \
38 -tab " " -pfx ">" -sep "$accnsfx" -element "&ACCN,protein_id" -rst \
39 -bkt gene -element gene \
40 -bkt protein -element product \
41 -bkt protein_id -element protein_id \
42 -bkt location -element location \
43 -bkt gbkey -element feature_key -clr \
44 -rst -deq "\n" -sep "\n" -fasta "$seqtype" -rst -deq "\n"