Kontent qismiga oʻtish

Andoza:Clade newick converter/doc

Vikipediya, ochiq ensiklopediya

Wikitext list converter

[manbasini tahrirlash]

Converts a list in wikitext marker to the clade structure. The list must be wrapped in <nowiki>...</nowiki> tags.

{{clade converter|list=<nowiki>
* ''Sitta''
** [[Sittelle superbe]] (''S. formosa'')
** 
*** 
**** [[Sittelle des rochers]] (''S. tephronota'')
**** [[Sittelle de Neumayer]] (''S. neumayer'')
***
**** 
***** [[Sittelle du Cachemire]] (''S. cashmirensis'')
***** '''Sittelle des Naga''' (''S. nagaensis'')
***** [[Sittelle torchepot]] (''S. europaea'')
**** [[Sittelle de l'Himalaya]] (''S. himalayensis'')
</nowiki>
}}

Alternatively invoke function directly:

{{#invoke:Clade|listConverter|list=
PUT LIST HERE
}}
produces
* ''Sitta''
** [[Sittelle superbe]] (''S. formosa'')
** 
*** 
**** [[Sittelle des rochers]] (''S. tephronota'')
**** [[Sittelle de Neumayer]] (''S. neumayer'')
***
**** 
***** [[Sittelle du Cachemire]] (''S. cashmirensis'')
***** '''Sittelle des Naga''' (''S. nagaensis'')
***** [[Sittelle torchepot]] (''S. europaea'')
**** [[Sittelle de l'Himalaya]] (''S. himalayensis'')
{{clade
|label1= ''Sitta''
|1={{clade
   |1= [[Sittelle superbe]] (''S. formosa'')
   |label2= 
   |2={{clade
      |label1= 
      |1={{clade
         |1= [[Sittelle des rochers]] (''S. tephronota'')
         |2= [[Sittelle de Neumayer]] (''S. neumayer'')
         }}
      |label2=
      |2={{clade
         |label1= 
         |1={{clade
            |1= [[Sittelle du Cachemire]] (''S. cashmirensis'')
            |2= '''Sittelle des Naga''' (''S. nagaensis'')
            |3= [[Sittelle torchepot]] (''S. europaea'')
            }}
         |2= [[Sittelle de l'Himalaya]] (''S. himalayensis'')
         }}
      }}
   }}
}}

Newick converter

[manbasini tahrirlash]

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.

  • |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.

The following code

{{Template:Clade newick converter
|newickstring=((lion,jaguar,leopard),((siberian,javan,bengal)tiger,snow leopard))panthera
|indent=10
}}

produces the output below

((lion,jaguar,leopard),((siberian,javan,bengal)tiger,snow leopard))panthera
{{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

[manbasini tahrirlash]

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

(''P. planiceps'',(((''P. b. chinensis'',''P. b. euptilurus'',''P. b. bengalensis'',''P. b. rabori'')''P. bengalensis'',''P. iriomotensis''),''P. viverrinus''),''P. rubiginosus'')''Prionailurus''
{{clade
|label1=''Prionailurus''
|1={{clade
   |1=''P. planiceps''
   |label2=
   |2={{clade
      |label1=
      |1={{clade
         |label1=''P. bengalensis''
         |1={{clade
            |1=''P. b. chinensis''
            |2=''P. b. euptilurus''
            |3=''P. b. bengalensis''
            |4=''P. b. rabori''
            }}
         |2=''P. iriomotensis''
         }}
      |2=''P. viverrinus''
      }}
   |3=''P. rubiginosus''
   }}
}}

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

[manbasini tahrirlash]

Converts a Wikitext-like list to a clade structure. The list uses the symbol @ as the * would be processed as Wikitext.

The following illustrates the code and the desired output:

Template call with pseudo-Wikitext listOutput of template as clade codeThe 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
}}
@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
      }}
   }}
Andoza:CladeN