Browse Source

Merge branch 'develop'

master
Damien Goutte-Gattat 8 years ago
parent
commit
9160c83c7c
1 changed files with 137 additions and 103 deletions
  1. +137
    -103
      flygenet.dtx

+ 137
- 103
flygenet.dtx View File

@ -43,7 +43,7 @@ has been generated for details.
%</batchfile>
%
%<*driver>
\ProvidesFile{flygenet.dtx}[2013/07/14 v0.1 Fly genetics notation]
\ProvidesFile{flygenet.dtx}[2013/10/09 v0.2 Fly genetics notation]
\documentclass[a4paper]{ltxdoc}
\usepackage{hyperref}
\usepackage{flygenet}
@ -56,7 +56,7 @@ has been generated for details.
%</driver>
% \fi
%
% \CheckSum{110}
% \CheckSum{0}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@ -74,22 +74,23 @@ has been generated for details.
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \DoNotIndex{\,}
% \DoNotIndex{\active}
% \DoNotIndex{\begingroup}
% \DoNotIndex{\catcode}
% \DoNotIndex{\DeclareOption,\def}
% \DoNotIndex{\else,\empty,\end,\endgroup}
% \DoNotIndex{\DeclareOption,\def,\draw}
% \DoNotIndex{\else,\empty,\end,\endgroup,\ensuremath}
% \DoNotIndex{\fi,\frac}
% \DoNotIndex{\gdef}
% \DoNotIndex{\ifx}
% \DoNotIndex{\height}
% \DoNotIndex{\if,\ifmmode,\ifx,\itshape}
% \DoNotIndex{\let}
% \DoNotIndex{\mars,\mathchardef,\mathit,\mercury}
% \DoNotIndex{\NeedsTeXFormat}
% \DoNotIndex{\mars,\mathchoice,\mbox,\mercury}
% \DoNotIndex{\NeedsTeXFormat,\newif,\node,\normalsize}
% \DoNotIndex{\ProcessOptions,\ProvidesPackage}
% \DoNotIndex{\RequirePackage,\relax}
% \DoNotIndex{\RequirePackage,\raisebox,\relax}
% \DoNotIndex{\tikz}
% \DoNotIndex{\venus}
%
% \changes{0.1}{2013/07/14}{Initial version.}
% \changes{0.2}{2013/10/09}{Remove limitations.}
%
% \GetFileInfo{flygenet.dtx}
%
@ -102,6 +103,7 @@ has been generated for details.
% 2 rue Robert Escarpit, 33607 Pessac, France}\\
% \texttt{d.goutte-gattat@iecb.u-bordeaux.fr}}
% \date{\filedate}
% \let\ts\textsuperscript
%
% \maketitle
%
@ -113,7 +115,7 @@ has been generated for details.
% notation, as in the following example:
%
% $$
% \genotype{C(1)RM,y^2/Y; In(2LR)O, Cy cn^2 sp^2/Sco; ci^D/ey^D}
% \genotype{C(1)RM,y\ts2/Y; In(2LR)O, Cy cn\ts2 sp\ts2/Sco; ci\ts D/ey\ts D}
% $$
%
% Consequently, \LaTeX's math mode (and especially displayed math mode,
@ -122,18 +124,22 @@ has been generated for details.
% However, typesetting a genotype can be quite tedious, as it requires
% many calls to the |\frac| macro (or the |\over| primitive) and
% constant use of manual spacing to override \TeX's
% math-mode spacing.
% math-mode spacing. And besides, to my knowledge there is no easy way
% to get the harpoon-like fraction bar needed to represent a Y
% chromosome.
%
% This package is intended to reduce the amount of code needed to
% typeset a genotype. For example, the genotype above is the result of
% the following code:
%
% \begin{verbatim}
% \genotype{C(1)RM,y^2/Y; In(2LR)O,Cy cn^2 sp^2/Sco; ci^D/ey^D}
% \let\ts\textsuperscript
% \genotype{C(1)RM,y\ts2/Y; In(2LR)O,Cy cn\ts2 sp\ts2/Sco; ci\ts D/ey\ts D}
% \end{verbatim}
%
% A complete genotype can thus be written in a very intuitive way, the
% only \TeX ism being the exponentiation symbol (|^|).
% only \TeX ism being the exponentiation macro, |\ts|, which is defined
% here as an alias for the |\textsuperscript| macro.
%
%
% \section{User interface}
@ -143,6 +149,10 @@ has been generated for details.
% chromosome pairs and slashes to separate the two chromosomes of a
% pair.
%
% A pair without any slash denotes a homozygous chromosome pair. If the
% second chromosome of a pair is only ``Y'', that pair is assumed to be
% a male sexual pair (XY).
%
% The macros |\female|, |\male|, and |\virgin| are used in the same way
% and perform the same task as |\genotype|, but they insert a female
% (\venus), male (\mars), or virgin female (\mercury) symbol in front of
@ -161,41 +171,6 @@ has been generated for details.
% several individuals of the indicated genotype.
%
%
% \section{Limitations}
%
% Homozygous chromosome must be written with an ending slash, as in the
% following example:
%
% \begin{minipage}{.6\textwidth}
% \begin{verbatim}
% \genotype{cn bw/;TM2/tra}
% \end{verbatim}
% \end{minipage}
% \begin{minipage}{.3\textwidth}
% $$
% \genotype{cn bw/;TM2/tra}
% $$
% \end{minipage}
%
% \bigskip
% When used as an argument to another macro, |\genotype| cannot control
% spacing; spaces between gene symbols must be added manually.
%
% \begin{minipage}{.6\textwidth}
% \begin{verbatim}
% \underbrace{\genotype{cn bw/;TM2/tra}}
% \quad
% \underbrace{\genotype{cn\ bw/;TM2/tra}}
% \end{verbatim}
% \end{minipage}
% \begin{minipage}{.3\textwidth}
% $$
% \underbrace{\genotype{cn bw/;TM2/tra}}
% \quad
% \underbrace{\genotype{cn\ bw/;TM2/tra}}
% $$
% \end{minipage}
%
% ^^A Inserts the LPPL text.
% \providecommand{\LPPLsection}{\section}
% \providecommand{\LPPLsubsection}{\subsection}
@ -211,7 +186,7 @@ has been generated for details.
% We start by identifying the package.
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2003/12/01]
\ProvidesPackage{flygenet}[2013/07/14 v0.1 Fly genetics notation]
\ProvidesPackage{flygenet}[2013/10/09 v0.2 Fly genetics notation]
% \end{macrocode}
%
% We load the |wasysym| package, that we will use to typeset the female
@ -220,72 +195,131 @@ has been generated for details.
\RequirePackage{wasysym}
% \end{macrocode}
%
% \subsection{Typesetting genotypes}
% We load the |tikz| package, that we will use to draw the Y chromosome
% symbol.
% \begin{macrocode}
\RequirePackage{tikz}
% \end{macrocode}
%
%
% \subsection{Helper macros}
%
% \begin{macro}{\fly@printchromosome}
% This macro typesets a single chromosome pair, as a mathematical
% fraction.
% \begin{macro}{\FG@mbox}
% This macro is intended to be used in math mode. It typesets its
% argument as normal, italicized text. The rationale behind this macro
% is that we need a |\mbox| to prevent LaTeX from applying math mode
% rules when parsing genotypes (regarding spacing and special
% characters); but |\mbox| alone also prevent the automatic sizing of
% the text depending on its location within a math expression.
% \begin{macrocode}
\def\fly@printchromosome#1/#2\end{%
\def\fly@argii{#2}%
\ifx\fly@argii\empty\mathit{#1}\else\frac{\mathit{#1}}{\mathit{#2}}\fi}
\def\FG@mbox#1{\mathchoice%
{\mbox{\normalsize\itshape #1}}%
{\mbox{\normalsize\itshape #1}}%
{\mbox{\scriptsize\itshape #1}}%
{\mbox{\scriptsize\itshape #1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fly@parsechromosome}
% This macro parses a genotype notation (chromosome pairs separated by
% semi-colons), and calls the |\fly@printchromosome| for each chromosome
% pair.
% \begin{macro}{\FG@findslash}
% This macro determines whether its argument contains a forward slash,
% and sets the |\ifFG@foundslash| boolean accordingly.
% \begin{macrocode}
\def\fly@parsechromosome#1;#2\end{%
\fly@printchromosome#1\end%
\def\fly@argii{#2}%
\ifx\fly@argii\empty\else; \fly@parsechromosome#2\end\fi}
\newif\ifFG@foundslash\FG@foundslashfalse
\def\FG@findslash#1/#2\end{%
\def\FG@argii{#2}%
\ifx\FG@argii\empty\FG@foundslashfalse\else\FG@foundslashtrue\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mhyphen}
% \begin{macro}{\mcolon}
% These two macros are used to typeset actual hyphens and colons in math
% mode.
%
% \subsection{Typesetting chromosomes}
%
% \begin{macro}{\FGChromosome}
% This macro typesets a single chromosome.
% \begin{macrocode}
\mathchardef\mhyphen="2D
\mathchardef\mcolon="3A
\def\FGChromosome#1{\ifmmode\mbox{\itshape #1}\else{\itshape #1}\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FGXYPair}
% This macro typesets a pair of X/Y sexual chromosomes. It is intended
% to look like a half-fraction, with the genotype as the numerator and
% without a denumerator, and with a downward hook at the right end of
% the fraction bar.
%
% We first define two helper macros that will do the actual work of
% drawing the genotype.
% \begin{macrocode}
\def\FG@XYPair@display#1{%
\tikz{%
\node[inner sep=.9ex] (y) {\raisebox{0pt}[\height][0pt]{\normalsize\itshape #1}};
\draw[line cap=round] (y.south west) -- (y.south east) -- ++(-0.1,-0.1);
}}
\def\FG@XYPair@inline#1{%
\tikz{%
\node[inner sep=.3ex] (y) {\raisebox{0pt}[\height][0pt]{\scriptsize\itshape #1}};
\draw[line cap=round] (y.south west) -- (y.south east) -- ++(-0.1,-0.1);
}}
% \end{macrocode}
%
% Then, we define the public macro, in which we call the appropriate
% helper macro depending on the math mode we are in.
% \begin{macrocode}
\def\FGXYPair#1{%
\ifmmode\mathchoice%
{\FG@XYPair@display{#1}}%
{\FG@XYPair@inline{#1}}%
{\FG@XYPair@inline{#1}}%
{\FG@XYPair@inline{#1}}%
\else\FG@XYPair@inline{#1}\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fly@endgenotype}
% This macro is called at the end of the |\genotype| macro. It performs
% the task of parsing and typesetting the genotype and reset the
% modified catcodes.
% \begin{macro}{\FGChrPair}
% This macro typesets a chromosome pair. If the second argument is
% non-empty, the genotype is typeset as a fraction; an empty second
% argument denotes a homozygous pair which is typeset on a single line.
% As a special case, if the second argument is equal to ``Y'', this
% denotes a male sexual pair (X/Y) which is typeset using the
% |\FGXYPair| macro.
% \begin{macrocode}
\def\fly@endgenotype#1{%
\fly@parsechromosome#1;\end%
\catcode`\ =10\relax%
\catcode`\-=12\relax%
\catcode`\:=12\relax}
\def\FGChrPair#1#2{%
\def\FG@argii{#2}%
\ifx\FG@argii\empty\FGChromosome{#1}\else%
\if\FG@argii Y\FGXYPair{#1}\else%
\ensuremath{\frac{\FG@mbox{#1}}{\FG@mbox{#2}}}%
\fi%
\fi}
% \end{macrocode}
% \end{macro}
%
% \subsection{Typesetting genotypes}
%
% \begin{macro}{\FG@printchromosome}
% This macro typesets a single chromosome pair, presented as delimited
% arguments.
% \begin{macrocode}
\def\FG@printchromosome#1/#2\end{\ensuremath{\FGChrPair{#1}{#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FG@parsechromosome}
% This macro parses a genotype notation (chromosome pairs separated by
% semi-colons), and calls the |\FG@printchromosome| for each chromosome
% pair.
% \begin{macrocode}
\def\FG@parsechromosome#1;#2\end{%
\FG@findslash#1/\end%
\ifFG@foundslash\FG@printchromosome#1\end\else\FG@printchromosome#1/\end\fi%
\def\FG@argii{#2}%
\ifx\FG@argii\empty\else; \FG@parsechromosome#2\end\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\genotype}
% This macro is the main user interface to typeset a genotype. Its
% declaration is enclosed in a group since we need to locally modify the
% catcodes of some characters. For the same reason, the macro cannot be
% declared as expecting an argument (otherwise, the argument would be
% parsed before the catcodes are modified)---the argument is parsed when
% calling the |\fly@endgenotype| macro.
% This macro is the main user interface to typeset a genotype.
% \begin{macrocode}
\begingroup
\catcode`\ =\active
\catcode`\-=\active
\catcode`\:=\active
\gdef\genotype{%
\catcode`\ =\active\let =\ %
\catcode`\-=\active\let-=\mhyphen%
\catcode`\:=\active\let:=\mcolon%
\fly@endgenotype}
\endgroup
\def\genotype#1{\FG@parsechromosome#1;\end}
% \end{macrocode}
% \end{macro}
%
@ -299,9 +333,9 @@ has been generated for details.
% the beginning. This is intended as an abstraction layer above the
% |wasysym| package providing these symbols.
% \begin{macrocode}
\def\female{\venus\;\genotype}
\def\male{\mars\;\genotype}
\def\virgin{\mercury\;\genotype}
\def\female{\venus\,\genotype}
\def\male{\mars\,\genotype}
\def\virgin{\mercury\,\genotype}
% \end{macrocode}
% \end{macro}
% \end{macro}
@ -315,9 +349,9 @@ has been generated for details.
% convention, this is used to represent several individuals of the
% indicated genotype.
% \begin{macrocode}
\def\females{\venus\venus\;\genotype}
\def\males{\mars\mars\;\genotype}
\def\virgins{\mercury\mercury\;\genotype}
\def\females{\venus\venus\,\genotype}
\def\males{\mars\mars\,\genotype}
\def\virgins{\mercury\mercury\,\genotype}
% \end{macrocode}
% \end{macro}
% \end{macro}


Loading…
Cancel
Save