IUBio

ASM2BIB.AWK

POSTMAST at GUNBRF.bitnet POSTMAST at GUNBRF.bitnet
Thu Feb 27 17:07:00 EST 1992


Distribution-File:
        "BIO-SOFT at genbank.bio.net"
        Schneider
        "marvin at molbio.cbs.umn.edu"
        "moberg at cis.ohio-state.edu"
        "prm at aber.ac.uk"

# ASM2BIB.AWK
# AWK script for conversion of ASM journal table of contents files to BibTex
# Version 2.0
#  1-MAY-1991 written by John S. Garavelli
# 27-FEB-1992 revised by John S. Garavelli for ASM journal format, to remove
#             gsub function, and add tags
#
# This script should work for these journals
# J. Bacteriol., J. Virol., Mol. Cell. Biol.
#
# Here is a model entry:
#AU Wolfgang Goedecke, Walter Vielmetter, and Petra Pfeiffer
#TI "Activation of a System for the Joining of Nonhomologous DNA Ends during
#   Xenopus Egg Maturation.";
#SO Mol. Cell. Biol. 12:811-816(1992)
#//
#
# Report problems to POSTMASTER at GUNBRF.BITNET

{ if ($1 == "CC" && index($0, "No.")) {
    for (i = 1; i<=NF ; i++) if ($(i) == "No.") break
    thenumber = $(i+1)
  }
}

{ if (substr($0, 0, 2) == "  ") {
    if (authorflag) theauthor = theauthor substr($0, 3, 80)
    else if (titleflag) thetitle = thetitle substr($0, 3, 80)
  }
}

{ if ($1 == "AU") {
    authorflag = 1
    titleflag = 0
    theauthor = substr($0, 4, 80)
  }
}

{ if ($1 == "TI") {
    authorflag = 0
    titleflag = 1
    thetitle = substr($0, 4, 80)
  }
}

{ if ($1 == "SO") {
    authorflag = 0
    titleflag = 0
    vpy = $(NF)
    thejournal = $2
    for (i = 3; i < NF; i++) { thejournal = thejournal " " $(i) }
    split(vpy, cluster, ":")
    thevolume = cluster[1]
    mark = index(cluster[2], "(")
    thepages = substr(cluster[2], 1, mark-1)
    theyear = substr(cluster[2], mark+1, 4)
    while ((i = index(theauthor, ", "))) {
      if (substr(theauthor, i+2, 2) == "Jr"  ||
          substr(theauthor, i+2, 4) == "and ") {
        theauthor = substr(theauthor, 1, i-1) substr(theauthor, i+1)
      }
      else theauthor = substr(theauthor, 1, i-1) " and" substr(theauthor, i+1)
    }
    temp = theauthor
    tag = ""
    k = 0
    while ((i = index(temp, " and ")) && k<2) {
      for (j=i-1; j>0; j--) if (substr(temp, j, 1) == " ") break
      tag = tag substr(temp, j+1, i-j-1) "."
      temp = substr(temp, i+5)
      k++
    }
    if (k < 2) {
      i = length(temp)
      for (j=i-1; j>0; j--) if (substr(temp, j, 1) == " ") break
      tag = tag substr(temp, j+1) "."
    }
    tag = tag theyear
    if (substr(thetitle, 1, 1) == "\"") start = 2
    else start = 1
    end = length(thetitle)
    if (substr(thetitle, end-1, 2) == "\";") end -= 2
    end -= start - 1
    thetitle = substr(thetitle, start, end)

    printf("@article{%s,\n", tag)
    printf("  author = \"%s\",\n", theauthor)
    printf("   title = \"%s\",\n", thetitle)
    printf(" journal = \"%s\",\n", thejournal)
    printf("    year = %s,\n", theyear)
    printf("  volume = \"%s\",\n", thevolume)
    if (thenumber != "") printf("  number = \"%s\",\n", thenumber)
    printf("   pages = \"%s\"\n}\n\n", thepages)
  }
}




More information about the Bio-soft mailing list

Send comments to us at biosci-help [At] net.bio.net