| 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 PubmedArticle XML to Pubmed-entry text ASN.1 |
| 7 |
|
| 8 |
# efetch -db pubmed -id 2539356,1937004 -format xml | pma2pme -std |
| 9 |
|
| 10 |
# can produce XML intermediate for archiving |
| 11 |
xml=false |
| 12 |
|
| 13 |
# default output uses original ml authors |
| 14 |
AUTHTYPE="AUTHML" |
| 15 |
|
| 16 |
# check for author type and XML output flags |
| 17 |
while [ $# -gt 0 ] |
| 18 |
do |
| 19 |
case "$1" in |
| 20 |
std | STD | -std | -STD ) |
| 21 |
# std has separate last name and initials fields |
| 22 |
AUTHTYPE="AUTHSTD" |
| 23 |
shift |
| 24 |
;; |
| 25 |
ml | ML | -ml | -ML ) |
| 26 |
# ml uses traditional Medline author format (default) |
| 27 |
shift |
| 28 |
AUTHTYPE="AUTHML" |
| 29 |
;; |
| 30 |
xml | -xml ) |
| 31 |
# do not convert to ASN.1 |
| 32 |
shift |
| 33 |
xml=true |
| 34 |
;; |
| 35 |
asn | -asn ) |
| 36 |
# convert to ASN.1 (default) |
| 37 |
shift |
| 38 |
xml=false |
| 39 |
;; |
| 40 |
* ) |
| 41 |
exec >&2 |
| 42 |
echo "$0: Unrecognized argument $1" |
| 43 |
exit 1 |
| 44 |
;; |
| 45 |
esac |
| 46 |
done |
| 47 |
|
| 48 |
# conversion function |
| 49 |
ConvertXMLtoASN() { |
| 50 |
|
| 51 |
transmute -mixed -normalize pubmed | |
| 52 |
xtract -strict -rec PM -pattern PubmedArticle -PS "()" \ |
| 53 |
-wrp PMID -element MedlineCitation/PMID \ |
| 54 |
-group PubmedData -PS PublicationStatus \ |
| 55 |
-group PubmedData/History/PubMedPubDate \ |
| 56 |
-if "@PubStatus" -equals pubmed -pkg EMDATE/em_std \ |
| 57 |
-wrp year_ -element Year \ |
| 58 |
-wrp month_ -element Month \ |
| 59 |
-wrp day_ -element Day \ |
| 60 |
-group MedlineCitation -pkg TITL \ |
| 61 |
-wrp name -prose ArticleTitle \ |
| 62 |
-group AuthorList -pkg AUTHSTD/authors/names_std \ |
| 63 |
-branch Author \ |
| 64 |
-block Author -pkg "_" \ |
| 65 |
-subset Author -pkg name_name \ |
| 66 |
-wrp last -author LastName \ |
| 67 |
-wrp initials -author Initials \ |
| 68 |
-subset Affiliation \ |
| 69 |
-wrp affil_str -prose Affiliation \ |
| 70 |
-group AuthorList -pkg AUTHML/authors/names_std \ |
| 71 |
-branch Author \ |
| 72 |
-block Author -pkg "_" \ |
| 73 |
-subset Author \ |
| 74 |
-wrp name_ml -sep " " -author LastName,Initials \ |
| 75 |
-subset Affiliation \ |
| 76 |
-wrp affil_str -prose Affiliation \ |
| 77 |
-group Article -pkg JOUR \ |
| 78 |
-block Journal -pkg JTAS/title \ |
| 79 |
-wrp iso-jta -element ISOAbbreviation \ |
| 80 |
-wrp ml-jta -element ISOAbbreviation \ |
| 81 |
-wrp issn -element ISSN \ |
| 82 |
-wrp name -element Title \ |
| 83 |
-branch Article -pkg IMP/imp \ |
| 84 |
-block PubDate -pkg date_std \ |
| 85 |
-wrp year_ -year "PubDate/*" \ |
| 86 |
-wrp month_ -month "PubDate/*" \ |
| 87 |
-wrp day_ -element PubDate/Day \ |
| 88 |
-block JournalIssue \ |
| 89 |
-wrp volume -element Volume \ |
| 90 |
-wrp issue -element Issue \ |
| 91 |
-block Article \ |
| 92 |
-wrp pages -element MedlinePgn \ |
| 93 |
-wrp language -element Language \ |
| 94 |
-wrp pubstatus_ -element "&PS" \ |
| 95 |
-group PubmedData/ArticleIdList -pkg IDS/ids \ |
| 96 |
-block ArticleId -if "@IdType" -equals pubmed \ |
| 97 |
-wrp pubmed_ -element ArticleId \ |
| 98 |
-block ArticleId -if "@IdType" -equals pmc \ |
| 99 |
-pfx "<other><db>pmc</db><tag_str>" \ |
| 100 |
-sfx "</tag_str></other>" -element ArticleId \ |
| 101 |
-block ArticleId -if "@IdType" -equals doi \ |
| 102 |
-wrp doi -element ArticleId \ |
| 103 |
-group MedlineCitation -pkg ABST/abstract \ |
| 104 |
-block Abstract/AbstractText \ |
| 105 |
-wrp " " -pfx "" -sfx "" -sep ": " -tab " " \ |
| 106 |
-prose "AbstractText@Label,AbstractText" | |
| 107 |
xtract -rec Pubmed-entry -pattern PM \ |
| 108 |
-PS PS/pubstatus_ \ |
| 109 |
-wrp pmid_ -element PMID \ |
| 110 |
-division PM -pkg medent \ |
| 111 |
-group EMDATE/em_std -element "*" \ |
| 112 |
-group PM -pkg cit \ |
| 113 |
-branch TITL/name -pkg title -element "*" \ |
| 114 |
-branch ${AUTHTYPE}/authors -element "*" \ |
| 115 |
-branch JOUR -pkg from_journal \ |
| 116 |
-block JTAS/title -element "*" \ |
| 117 |
-block IMP/imp -element "*" \ |
| 118 |
-branch IDS/ids -element "*" \ |
| 119 |
-group ABST/abstract -element "*" |
| 120 |
} |
| 121 |
|
| 122 |
if [ "$xml" = true ] |
| 123 |
then |
| 124 |
ConvertXMLtoASN |
| 125 |
else |
| 126 |
ConvertXMLtoASN | xtract -pattern Pubmed-entry -element "." |
| 127 |
fi |