Template:Clade converter
![]() | This template uses Lua: |
Contents
Newick Converter
Convert simple Newick strings to the clade structure. This is a tool to aid construction of cladograms using the {{clade}} template and not for use directly in the article namespace.
Parameters
|newickstring=
– the Newick format data to be converted|indent=
– optionally set an indent, which will indent every line by N spaces. This can help alignment in the final cladogram.
Example
The following code
{{Template:Clade newick converter |newickstring=((lion,jaguar,leopard),((siberian,javan,bengal)tiger,snow leopard))panthera |indent=10 }}
produces the output below
- Modified Newick string:
((lion,jaguar,leopard),((siberian,javan,bengal)tiger,snow leopard))panthera
Output of clade template structure:{{clade |label1=panthera |1={{clade |label1= |1={{clade |1=lion |2=jaguar |3=leopard }} |label2= |2={{clade |label1=tiger |1={{clade |1=siberian |2=javan |3=bengal }} |2=snow leopard }} }} }}
Processing the Newick string
The Newick format data provided Open Tree of Life and other sources typically has extraneous encoding data. This extra information can be removed using the |newickN-pattern=
and |newickN-replace=
parameters which supply a Lua pattern (similar to Regex) and replacement. The following code uses Newick format data for the genus Prionailurus downloaded from using Open Tree of Life (source data):
{{clade newick converter |newickstring=(Prionailurus_planiceps_ott86166,(((Prionailurus_bengalensis_chinensis_ott198595,Prionailurus_bengalensis_euptilurus_ott547362,Prionailurus_bengalensis_bengalensis_ott5557509,Prionailurus_bengalensis_rabori_ott7067613)Prionailurus_bengalensis_ott280108,Prionailurus_iriomotensis_ott418475),Prionailurus_viverrinus_ott862641),Prionailurus_rubiginosus_ott507541)Prionailurus_ott570215 |newick-pattern=([%a_]+)_(ott[%d]*) |newick-replace={{'}}{{'}}%1{{'}}{{'}} |newick-pattern2=(%a)(%l+)_ |newick-replace2=%1._ }}
produces
- Modified Newick string:
(Prionailurus planiceps ott86166,(((Prionailurus bengalensis chinensis ott198595,Prionailurus bengalensis euptilurus ott547362,Prionailurus bengalensis bengalensis ott5557509,Prionailurus bengalensis rabori ott7067613)Prionailurus bengalensis ott280108,Prionailurus iriomotensis ott418475),Prionailurus viverrinus ott862641),Prionailurus rubiginosus ott507541)Prionailurus ott570215
Output of clade template structure:{{clade |label1=Prionailurus ott570215 |1={{clade |1=Prionailurus planiceps ott86166 |label2= |2={{clade |label1= |1={{clade |label1=Prionailurus bengalensis ott280108 |1={{clade |1=Prionailurus bengalensis chinensis ott198595 |2=Prionailurus bengalensis euptilurus ott547362 |3=Prionailurus bengalensis bengalensis ott5557509 |4=Prionailurus bengalensis rabori ott7067613 }} |2=Prionailurus iriomotensis ott418475 }} |2=Prionailurus viverrinus ott862641 }} |3=Prionailurus rubiginosus ott507541 }} }}
In this example there are two replacements. The first strips the _ott suffix and applies Wikitext markup. Note the Wikitext markup has to be handled with a template ({{'}}
) The second abbreviates the genus name when not standalone. In addition, underscores are always replaced by spaces.
List Converter
Converts a Wikitext-like list to a clade structure. The list uses the symbol @ as the * would be processed as Wikitext.
Example
The following illustrates the code and the desired output:
Template call with pseudo-Wikitext list | Output of template as clade code | The cladogram that the code produces | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{Clade converter |indent=3 |list= @A @@A1 @@A2 @B @C @@C1 @@C2 @@@C2a @@@C2b @@@@C2b1 @@@@C2b2 @@C3 @D @@D1 @@D2 }} |
{{clade |label1=A |1={{clade |1=A1 |2=A2 }} |2=B |label3=C |3={{clade |1=C1 |label2=C2 |2={{clade |1=C2a |label2=C2b |2={{clade |1=C2b1 |2=C2b2 }} }} |3=C3 }} |label4=D |4={{clade |1=D1 |2=D2 }} }} |
|
The above documentation is transcluded from Template:Clade converter/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |