Difference between revisions of "Template:Clade"
m (1 revision) |
Aliceingame (Talk | contribs) |
||
| Line 116: | Line 116: | ||
}} | }} | ||
| valign=top style="border: 0; padding: 0;" | <br/> | | valign=top style="border: 0; padding: 0;" | <br/> | ||
| − | |}<noinclude>{{ | + | |}<noinclude>{{doc}} |
[[Category:Templates|C]]</noinclude> | [[Category:Templates|C]]</noinclude> | ||
Latest revision as of 23:03, 16 May 2014
| |
{{{1}}} |
| |
This template is used for illustrating branching trees with the nodes and base labels being clickable links. They are especially suited to represent evolutionary trees.
Usage
{{clade
|label1=Base
|1=Node
}}
produces
| Base |
Node |
| |
{{clade
|1={{clade
|label1=[[Subtree1]]
|1=Leaf1
|label2=Subtree2
|2=[[Leaf2]]
}}
}}
produces
| |
| ||||||
| |
{{clade| style=font-size:75%;line-height:75%
|1={{clade
|label1=Subtree1
|1=Leaf1
|label2=Subtree2
|2=Leaf2
}}
}}
produces
| |
| ||||||
| |
{{clade
|1={{clade
|1={{clade | thickness=3
|1=Leaf1
|2=Leaf2
}}
|2=Leaf3
}}
}}
produces
| |
| ||||||||||||
| |
To replace the solid line with a dashed line, use |stateN=dashed:
{{clade
|1={{clade
|1={{clade
|1=Leaf1|state1=dashed
|2=Leaf2
}}
|2=Leaf3
}}
}}
produces
| |
| ||||||||||||
| |
Tips
An easy way of creating larger cladograms is to use the Newick format and proceed to edit it using a suitable text editor to produce the markup.
- Start with Newick format ((a,b),(c,d))
- Replace "(" with "{{clade|"
- Replace ")" with "}}"
- Edit to replace commas with pipes and numbers
- Edit clade labels if needed
{{clade
|1={{clade
|1=a
|2=b
}}
|2={{clade
|1=c
|2=d
}}
}}
Example Perl script to automate the conversion: <source lang="perl"> use constant N=>"\n"; use constant T=>"\t";
my $tree='((a,b),(c,d));'; # get sequence $tree=~s/[\n\r]//g; # loose those spaces $tree=~ s/\:[\.\d]+//g; # loose those lengths while ($tree=~ m/\(/) { foreach my $clade ($tree=~ m/\(([^\(\)]+)\)/g) { my @branches=split /\,/,$clade; s/(\t+)/$1\t/g for @branches; die 'ERROR: degenerate/empty node!'.N if $#branches<1; $tree=~ s/\(\Q$clade\E\)/${\join(,)}/; # substitute } pos($tree)=0; } $tree=~s/(\t*)\t\}\}/$1\}\}/g; # lazy fix
print $tree; </source>
Using a box
You can nest the templates and use links around the text. You may use non-breaking spaces ( ) to obtain spaces or to have labels that have spaces.
The entire cladogram can be placed in a box so that text flows nicely around it.