| 1 |
#!/bin/bash |
| 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 |
tform="" |
| 7 |
|
| 8 |
if [ $# -gt 0 ] |
| 9 |
then |
| 10 |
tform=$( cat "$1" ) |
| 11 |
fi |
| 12 |
|
| 13 |
hgvs=$( cat ) |
| 14 |
|
| 15 |
# hgvs=$( |
| 16 |
# efetch -db snp -id 104894914,104894915,104894916,11549407 -format docsum | |
| 17 |
# xtract -rec HGVS -pattern DocumentSummary -wrp Id -element Id -rst -hgvs DOCSUM | |
| 18 |
# transmute -format |
| 19 |
# ) |
| 20 |
|
| 21 |
# get location of first base of CDS for each NM accession |
| 22 |
|
| 23 |
TFORM() { |
| 24 |
echo "$1" | |
| 25 |
xtract -pattern Variant -if Offset -element Accession | |
| 26 |
sort -f | uniq -i | |
| 27 |
while read accn |
| 28 |
do |
| 29 |
efetch -db nuccore -id "$accn" -format gb | |
| 30 |
gbf2xml | |
| 31 |
xtract -pattern INSDSeq -ACCN INSDSeq_accession-version \ |
| 32 |
-group INSDFeature -if INSDFeature_key -equals CDS \ |
| 33 |
-tab "-" -element "&ACCN" -tab "|" -min INSDInterval_from | |
| 34 |
grep "-" | grep -v "|" | tr '-' '\t' |
| 35 |
done | |
| 36 |
print-columns '$1, $2-1' |
| 37 |
} |
| 38 |
|
| 39 |
if [ -z "$tform" ] |
| 40 |
then |
| 41 |
tform=$( TFORM "$hgvs" ) |
| 42 |
fi |
| 43 |
|
| 44 |
# tform=$( echo -e "NM_000513.2\t82\nNM_000518.5\t50\n" ) |
| 45 |
|
| 46 |
# add location of CDS start to CDS-relative offset to get sequence-relative position |
| 47 |
|
| 48 |
echo "$hgvs" | |
| 49 |
xtract -transform <( echo "$tform" ) \ |
| 50 |
-rec SPDI -pattern HGVS \ |
| 51 |
-wrp Id -element Id \ |
| 52 |
-wrp Gene -element Gene \ |
| 53 |
-group Variant \ |
| 54 |
-INSET -translate Accession -POSTN Position \ |
| 55 |
-block Variant -if Offset -and "&INSET" \ |
| 56 |
-POSTN -sum "Offset,&INSET" \ |
| 57 |
-block Variant -pkg Variant \ |
| 58 |
-wrp Class -element Class \ |
| 59 |
-wrp Type -element Type \ |
| 60 |
-wrp Accession -element Accession \ |
| 61 |
-wrp Position -element "&POSTN" \ |
| 62 |
-wrp Offset -element Offset \ |
| 63 |
-wrp Deleted -element Deleted \ |
| 64 |
-wrp Inserted -element Inserted \ |
| 65 |
-wrp Hgvs -element Hgvs \ |
| 66 |
-wrp Spdi -sep ":" -element Accession,"&POSTN",Deleted,Inserted | |
| 67 |
transmute -format |