#!/bin/tcsh -f #(ie run the tshell on this but don't read the .cshrc or .tcshrc) set version = "version = 1.02 of bibtex2pmcid 2008 Mar 25" # 2008 Mar 25, 1.02: official documentation and " on pmcid # 2008 Mar 25, 1.01: functional! # 2008 Mar 25, 1.00: origin # switch lines to turn on (1) or off (2) verbose mode: set verbosemode = 1 set verbosemode = 0 if ($#argv == 0) then echo "$version" echo 'bibtex2pmcid [input bibtex file]' echo 'Incorporate PubMedCentral numbers into a BibTeX database file.' echo 'Read the input file and identify lines that contain a' echo 'PubMed ID line with this format:' echo '' echo 'pmid = "15130839",' echo '' echo 'Then the corresponding PubMedCentral number is identified' echo 'using pmid2pmcid and incorporated by extending the line:' echo '' echo 'pmid = "15130839", pmcid = "1852464",' echo '' echo 'The rest of the file is just copied to the output.' echo '' echo 'The results are given to standard output.' echo '' echo 'PMCID is required by NIH:' echo 'Policy No. 118 3/10/08 Public Access Policy' echo 'http://web.ncifcrf.gov/campus/administrative/policies/100admin/118.asp' echo '' echo 'See also: pmid2pmcid' echo '' echo '---' echo '' echo 'Dr. Thomas D. Schneider' echo 'National Institutes of Health' echo 'National Cancer Institute' echo 'Center for Cancer Research Nanobiology Program' echo 'Molecular Information Theory Group' echo 'Frederick, Maryland 21702-1201' echo 'toms@ncifcrf.gov' echo 'permanent email: toms@alum.mit.edu' echo 'http://www.ccrnp.ncifcrf.gov/~toms/' exit endif # if ($verbosemode) then # echo "===== input file: $1 =====" # cat $1 # echo "==========================" # endif set tmp = /tmp/`whoami`1.bibtex2pmcid cat $1 |\ sed 's/^/BEGINALINE/' |\ cat > $tmp #cat $tmp #exit set number = 0 # foreach line ("`cat $1|sed 's/^/BEGINALINE/'`") # foreach line ("`cat $1|sed 's/^/BEGINALINE/'`") #foreach line ("`cat $1`") foreach line ("`cat $tmp`") # set cleanline = `echo "$line"|sed 's/BEGINALINE//'` @ number = "$number" + 1 # echo -n "$number" if (`echo "$line" | grep 'pmid = "'` == '') then # echo "$cleanline" |sed 's/BEGINALINE//' echo "$line" |sed 's/BEGINALINE//' else # process lines with pmid on them. if ($verbosemode) then # echo "$line" echo ===== "$line" |sed 's/BEGINALINE//' endif if (`echo $line | grep 'pmcid'` == '') then set p1 = `echo "$line"| sed 's,BEGINALINE,,'` set PMID = `echo "$p1"| sed 's,pmid = ",,'|sed 's/",//'` set PMCID = `pmid2pmcid $PMID` if ($verbosemode) then echo "===== PMID: $PMID ====== at line $number" echo "===== PMCID: $PMCID ====== at line $number" endif if ("$PMCID" == '') then if ($verbosemode) then echo 'NO PMCID FOUND at line $number' endif set new = "" else set new = 'pmcid = "'$PMCID'",' endif # echo "$line $new"` # set result = `echo "$line $new"` # set result = `echo "$line $new" |sed 's/BEGINALINE//'` # echo "$result" echo "$line $new" |sed 's/BEGINALINE//' else if ($verbosemode) then echo "===== The line already has a PMCID ===== at line $number" endif endif endif end exit ******************************************************************************** Example entries: @article{Schneider2002, author = "T. D. Schneider", title = "{Consensus sequence Zen}", journal = "Appl Bioinformatics", volume = "1", pages = "111--119", year = "2002"} @article{Schneider2002, author = "T. D. Schneider", title = "{Consensus sequence Zen}", journal = "Appl Bioinformatics", volume = "1", pages = "111--119", pmid = "15130839", year = "2002"} @article{Schneider2002, author = "T. D. Schneider", title = "{Consensus sequence Zen}", journal = "Appl Bioinformatics", volume = "1", pages = "111--119", pmid = "15130839", pmcid = 1852464, year = "2002"}