% molcellbiol.bst
% author:
%  Tom Schneider
%  NCI/FCRDC Bldg 469. Room 144
%  P.O. Box B
%  Frederick, MD  21702-1201
%  (301) 846-5581 (-5532 for messages)
%  (301) 846-5598 fax
%  email: toms@ncifcrf.gov
% modified by Christoph Clodo, 11/2005
% modified by Ingolf Sommer, 11/2005

STRINGS { version }
FUNCTION {version.identifier}
% identify the version of the program
{
"% version = 1.13 of molcellbiol.bst 1994 July 12"
duplicate$
write$ newline$
warning$
}

ENTRY
  { address
    author
    booktitle
    chapter
    edition
    editor
    howpublished
    institution
    journal
    key
    month
    note
    number
    organization
    pages
    publisher
    school
    series
    title
    type
    volume
    year
  }
  {}
  { label }

INTEGERS { dotitle % toggle switch for doing titles
 }
STRINGS { longest.label }
INTEGERS { number.label longest.label.width }
STRINGS { s t }

% ***********************************************************

FUNCTION{comma} { ", " write$ }
FUNCTION{period} { ". " write$ }
FUNCTION{leftparenthesis} { "(" write$ }
FUNCTION{rightparenthesis} { ") " write$ }

% ***********************************************************
% ***********************************************************

INTEGERS { nameptr namesleft numnames }

FUNCTION {format.names}
{ 's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    {
 
      % if there is only one name, don't put a period after it
      numnames #1 =
      {s nameptr "{vv~}{ll}{, jj}{, f}" format.name$ 't :=} % last name first
      { nameptr #1 =
        {s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=} % last name first
        {s nameptr "{~f.}{~vv~}{~ll}{, jj}" format.name$ 't :=} % first name first
        if$
      }
      if$

      nameptr #1 >
        { namesleft #1 >
            { ", " * t * }
            { numnames #2 >
                { " " * }
                'skip$
              if$
              t "others" =
                { " {\em et~al.}" * }
                { " and " * t * }
              if$
            }    
          if$
        }
        't
      if$ 
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

% ***********************************************************
% The following functions produce bibliography style

FUNCTION{startentry} { % start the entry
's := % pick up the entry name
"\bibitem{" write$
}

FUNCTION{endentry} { % end the entry
newline$
}

FUNCTION{makekey} {
cite$ "}" * write$
newline$
}

FUNCTION{makeauthor} {
"{\bf " write$
author format.names write$
".}" write$
newline$
}

% modified by Ingolf Sommer, 11/2005
FUNCTION{maketitle} {
title add.period$ write$
newline$
}

% modified by Ingolf Sommer, 11/2005
FUNCTION{makechapter} {
chapter add.period$ write$
newline$
}

FUNCTION{makejournal} {
journal write$
newline$
}

FUNCTION{makevolume} {
"{\bf " write$
volume write$
"}:" write$
}

FUNCTION{makepages} {
pages write$
"." write$
newline$
}

FUNCTION{makeyear} {
year write$
period
newline$
}

% modified by Ingolf Sommer, 11/2005
FUNCTION{makepublisher} {
publisher empty$
          {}
          {publisher write$ newline$}
if$
}

FUNCTION{makeaddress} {
address write$
newline$
}

% modified by Ingolf Sommer, 11/2005
FUNCTION{makeeditor} {
editor empty$
       {}
       {editor write$ newline$}
if$
}

FUNCTION{makebooktitle} {
booktitle write$
newline$
}

FUNCTION{makeschool} {
school write$
newline$
}

FUNCTION{makenote} {
note write$
"." write$
newline$
}

% ***********************************************************
% style defined functions

FUNCTION{article}
{
"article" startentry
makekey
makeauthor
makeyear
maketitle 
makejournal
makevolume
makepages
endentry
}

% Book in inbook modified by Christoph Clodo, 11/2005
% Book now has a "." at the end in accordance to article
% and inbook.
% Check for empty address added.
FUNCTION{book}
{
"book" startentry
makekey
makeauthor
makeyear
maketitle
%"{\em In }" write$
publisher write$
address empty$
	{ }
	{ newline$ address write$ }
if$
"." write$
endentry
}

% Book in inbook modified by Christoph Clodo, 11/2005
% Inbook now has a "." at the end in accordance to article
% and book. Pages added to the end.
% Check for empty address added.
FUNCTION{inbook}
{
"inbook" startentry
makekey
makeauthor
makeyear
makechapter
"In {\em{}" write$
title write$
"}," write$
newline$
makeeditor
"{(ed.), }" write$
publisher write$
address empty$
	{ }
	{ newline$ address write$ }
if$
", " write$
pages write$
"." write$
endentry
}

FUNCTION{inproceedings}
{
"inproceedings" startentry
makekey
makeauthor
maketitle
makeeditor
makebooktitle
makepublisher
makeyear
makepages
endentry
}

% incollection modified by Ingolf Sommer, 11/2005
FUNCTION{incollection}
{
"incollection" startentry
makekey
makeauthor
makeyear
maketitle
makeeditor
makebooktitle
makepublisher
makepages
endentry
}

FUNCTION{phdthesis}
{
"phdthesis" startentry
makekey
makeauthor
maketitle
makeschool
makeyear
endentry
}

FUNCTION{misc}
{
article
}

FUNCTION{unpublished}
{
"unpublished" startentry
makekey
makeauthor
makeyear
maketitle
% makejournal
% makevolume
% makepages
makenote
endentry
}

% ***********************************************************
 
FUNCTION {initialize.longest.label}
% initialize the variables for the longest.label.pass function
{ "" 'longest.label :=
  #1 'number.label :=
  #0 'longest.label.width :=
}
 
FUNCTION {longest.label.pass}
% determine the longest label in the references
{ number.label int.to.str$ 'label :=
  number.label #1 + 'number.label :=
  label width$ longest.label.width >
    { label 'longest.label :=
      label width$ 'longest.label.width :=
    }
    'skip$
  if$
}

% ***********************************************************

FUNCTION {begin.bib} { % begin the output file
  newline$
  preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
  "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  newline$
}

FUNCTION {end.bib} {  % end the output file
  "\end{thebibliography}" write$ newline$
}

% ***********************************************************

FUNCTION {bib.sort.order}
% Generate the sort.key$ variables for sorting.
{
%"================> in bib.sort.order"
%warning$
%  author #1 entry.max$ substring$
%warning$

%author
%"l"
%change.case$
%write$ newline$

  author                      % sort first on author list
    format.names      % put names in form used for printing
    purify$           % but ignore {} and so on!
    "l" change.case$  % and handle de Silva as De silva
  year  *                     % sort next on year
  title *                     % sort next on title
  #1 entry.max$ substring$ % can't use more than entry.max$ characters!
  'sort.key$ :=

% The following lines help debug the program.  It shows what the sort.key$ is.
%   "% ------" write$ newline$
%   "%" sort.key$ * #1 #79 substring$ write$ newline$

}

% ***********************************************************

READ


EXECUTE {version.identifier}
EXECUTE {initialize.longest.label}
ITERATE {longest.label.pass}

ITERATE {bib.sort.order} % set up the sorting keys
SORT                     % by author+year

EXECUTE {begin.bib}
ITERATE {call.type$}
EXECUTE {end.bib}
