%%
%% This is file `pgfmolbio.chromatogram.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pgfmolbio.dtx  (with options: `pmb-chr')
%% 
%% Copyright (C) 2011 by Wolfgang Skala
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
\ProvidesFile{pgfmolbio.chromatogram.tex}[2011/09/20 v0.1 SCF Chromatograms]

\RequireLuaModule{pgfmolbio.chromatogram}

\definecolor{pmbTraceGreen}{RGB}{34,114,46}
\definecolor{pmbTraceBlue}{RGB}{48,37,199}
\definecolor{pmbTraceBlack}{RGB}{0,0,0}
\definecolor{pmbTraceRed}{RGB}{191,27,27}
\definecolor{pmbTraceYellow}{RGB}{233,230,0}

\def\@pmb@chr@keydef#1{%
  \pgfkeysdef{/pgfmolbio/chromatogram/#1}{%
    \expandafter\def\csname pmb@chr@#1\endcsname{##1}%
  }%
}
\def\@pmb@chr@stylekeydef#1{%
  \pgfkeysdef{/pgfmolbio/chromatogram/#1}{%
    \pgfkeys{/pgfmolbio/chromatogram/#1@style/.style={##1}}%
  }%
}
\def\@pmb@chr@getkey#1{\csname pmb@chr@#1\endcsname}

\@pmb@chr@keydef{sample range}

\@pmb@chr@keydef{x unit}
\@pmb@chr@keydef{y unit}
\@pmb@chr@keydef{samples per line}
\@pmb@chr@keydef{baseline skip}
\@pmb@chr@stylekeydef{canvas style}
\@pmb@chr@keydef{canvas height}

\@pmb@chr@stylekeydef{trace A style}
\@pmb@chr@stylekeydef{trace C style}
\@pmb@chr@stylekeydef{trace G style}
\@pmb@chr@stylekeydef{trace T style}
\pgfkeysdef{/pgfmolbio/chromatogram/trace style}{%
  \pgfmolbioset[chromatogram]{
    trace A style={#1},
    trace C style={#1},
    trace G style={#1},
    trace T style={#1}
  }%
}
\@pmb@chr@keydef{traces drawn}

\@pmb@chr@stylekeydef{tick A style}
\@pmb@chr@stylekeydef{tick C style}
\@pmb@chr@stylekeydef{tick G style}
\@pmb@chr@stylekeydef{tick T style}
\pgfkeysdef{/pgfmolbio/chromatogram/tick style}{%
  \pgfmolbioset[chromatogram]{
    tick A style={#1},
    tick C style={#1},
    tick G style={#1},
    tick T style={#1}
  }%
}
\@pmb@chr@keydef{tick length}
\@pmb@chr@keydef{ticks drawn}

\@pmb@chr@keydef{base label A text}
\@pmb@chr@keydef{base label C text}
\@pmb@chr@keydef{base label G text}
\@pmb@chr@keydef{base label T text}
\@pmb@chr@stylekeydef{base label A style}
\@pmb@chr@stylekeydef{base label C style}
\@pmb@chr@stylekeydef{base label G style}
\@pmb@chr@stylekeydef{base label T style}
\pgfkeysdef{/pgfmolbio/chromatogram/base label style}{%
  \pgfmolbioset[chromatogram]{
    base label A style={#1},
    base label C style={#1},
    base label G style={#1},
    base label T style={#1}
  }%
}
\@pmb@chr@keydef{base labels drawn}

\newif\ifpmb@chr@showbasenumbers
\pgfkeys{/pgfmolbio/chromatogram/show base numbers/%
  .is if=pmb@chr@showbasenumbers}
\@pmb@chr@stylekeydef{base number style}
\@pmb@chr@keydef{base number range}

\@pmb@chr@keydef{probability distance}
\@pmb@chr@keydef{probabilities drawn}
\@pmb@chr@keydef{probability style function}

\pgfkeysdef{/pgfmolbio/chromatogram/bases drawn}{%
  \pgfmolbioset[chromatogram]{
    traces drawn=#1,
    ticks drawn=#1,
    base labels drawn=#1,
    probabilities drawn=#1
  }%
}

\pgfmolbioset[chromatogram]{%
  sample range=1 to 500 step 1,
  x unit=0.2mm,
  y unit=0.01mm,
  samples per line=500,
  baseline skip=3cm,
  canvas style={draw=none, fill=none},
  canvas height=2cm,
  trace A style={pmbTraceGreen},
  trace C style={pmbTraceBlue},
  trace G style={pmbTraceBlack},
  trace T style={pmbTraceRed},
  tick A style={thin, pmbTraceGreen},
  tick C style={thin, pmbTraceBlue},
  tick G style={thin, pmbTraceBlack},
  tick T style={thin, pmbTraceRed},
  tick length=1mm,
  base label A text=\strut A,
  base label C text=\strut C,
  base label G text=\strut G,
  base label T text=\strut T,
  base label A style=%
    {below=4pt, font=\ttfamily\footnotesize, pmbTraceGreen},
  base label C style=%
    {below=4pt, font=\ttfamily\footnotesize, pmbTraceBlue},
  base label G style=%
    {below=4pt, font=\ttfamily\footnotesize, pmbTraceBlack},
  base label T style=%
    {below=4pt, font=\ttfamily\footnotesize, pmbTraceRed},
  show base numbers,
  base number style={pmbTraceBlack, below=-3pt, font=\sffamily\tiny},
  base number range=auto to auto step 10,
  probability distance=0.8cm,
  probability style function=nil,
  bases drawn=ACGT
}

\newif\ifpmb@chr@tikzpicture

\newcommand\pmbchromatogram[2][]{%
  \@ifundefined{useasboundingbox}%
    {\pmb@chr@tikzpicturefalse\begin{tikzpicture}}%
    {\pmb@chr@tikzpicturetrue\begingroup}%
  \pgfmolbioset[chromatogram]{#1}%
  \directlua{
    pgfmolbio.chromatogram.readScfFile("#2")
    pgfmolbio.chromatogram.setParameters{
      sampleRange = "\@pmb@chr@getkey{sample range}",
      xUnit = dimen("\@pmb@chr@getkey{x unit}")[1],
      yUnit = dimen("\@pmb@chr@getkey{y unit}")[1],
      samplesPerLine = \@pmb@chr@getkey{samples per line},
      baselineSkip = dimen("\@pmb@chr@getkey{baseline skip}")[1],
      canvasHeight = dimen("\@pmb@chr@getkey{canvas height}")[1],
      tracesDrawn = "\@pmb@chr@getkey{traces drawn}",
      tickLength = dimen("\@pmb@chr@getkey{tick length}")[1],
      ticksDrawn = "\@pmb@chr@getkey{ticks drawn}",
      baseLabelsDrawn = "\@pmb@chr@getkey{base labels drawn}",
      showBaseNumbers = \ifpmb@chr@showbasenumbers true\else false\fi,
      baseNumberRange = "\@pmb@chr@getkey{base number range}",
      probDistance = dimen("\@pmb@chr@getkey{probability distance}")[1],
      probabilitiesDrawn = "\@pmb@chr@getkey{probabilities drawn}",
      probStyle = \@pmb@chr@getkey{probability style function}
    }
    pgfmolbio.chromatogram.printTikzChromatogram()
  }%
  \ifpmb@chr@tikzpicture\endgroup\else\end{tikzpicture}\fi%
}
\endinput
%%
%% End of file `pgfmolbio.chromatogram.tex'.
