Repository: biopython/biopython

Issue:
`Bio.Phylo.write` in format `nexus` does not export comments. 
### Setup

I am reporting a problem with Biopython version 1.77, Python version 3.7, and operating
system Ubuntu 16.04 as follows:

```python
from io import StringIO
from Bio import Phylo

t = Phylo.read(StringIO("((A,B),C);"), 'newick')

for ni,n in enumerate(t.get_terminals()):
    n.comment = f"[&node_number={ni}]"

out = StringIO()
Phylo.write(t, out, "nexus")
print(out.getvalue())
```
The output is
```
#NEXUS
Begin Taxa;
 Dimensions NTax=3;
 TaxLabels A B C;
End;
Begin Trees;
 Tree tree1=((A:0.00000,B:0.00000):0.00000,C:0.00000):0.00000;
End;
```
missing the comments I attached to the nodes. 

### Expected behaviour
The output should look like this:
```
Begin Taxa;
 Dimensions NTax=3;
 TaxLabels A B C;
End;
Begin Trees;
 Tree tree1=((A[&node_number=0]:0.00000,B[&node_number=1]:0.00000):0.00000,C[&node_number=2]:0.00000):0.00000;
End;
```
In fact, doing the reverse and parsing this tree with `Bio.Phylo.read` reads the comments correctly. 

```python
nexus_in = StringIO(
"""
Begin Taxa;
 Dimensions NTax=3;
 TaxLabels A B C;
End;
Begin Trees;
 Tree tree1=((A[&node_number=0]:0.00000,B[&node_number=1]:0.00000):0.00000,C[&node_number=2]:0.00000):0.00000;
End;
""")

t2 = Phylo.read(nexus_in, 'nexus')

for n in t2.get_terminals():
    print(n.name, n.comment)
```
has the expected output 
```
A [&node_number=0]
B [&node_number=1]
C [&node_number=2]
```

### Actual behaviour
`Bio.Phylo.write` in `nexus` format ignores comments, while `Bio.Phylo.read` correctly parses them from the input. 

### Steps to reproduce
The above code-snippets are sufficient to reproduce the unexpected behaviour. 


Discussion:
Hmm, looking at the code https://github.com/biopython/biopython/blob/biopython-178/Bio/Phylo/NexusIO.py how this might be done is not obvious to me. Over to Eric...
FYI: this code works fine in Biopython 1.70:
```python
\:> python
Python 3.6.12 |Anaconda, Inc.| (default, Sep  8 2020, 23:10:56) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Bio
>>> print(Bio.__version__)
1.70
>>> from io import StringIO
>>> from Bio import Phylo
>>> 
>>> t = Phylo.read(StringIO("((A,B),C);"), 'newick')
>>> 
>>> for ni,n in enumerate(t.get_terminals()):
...     n.comment = f"[&node_number={ni}]"
... 
>>> out = StringIO()
>>> Phylo.write(t, out, "nexus")
1
>>> print(out.getvalue())
#NEXUS
Begin Taxa;
 Dimensions NTax=3;
 TaxLabels A B C;
End;
Begin Trees;
 Tree tree1=((A:0.00000[\[&node_number=0\]],B:0.00000[\[&node_number=1\]]):0.00000,C:0.00000[\[&node_number=2\]]):0.00000;
End;

>>> 
```
version 1.76 also works, 1.77 doesn't. (and yes, my example comments have extra `[..]`)

would be great if this got fixed -- thanks for all the work!
Sounds like you are most of the way to working what changed between 1.76 and 177, perhaps just from browsing the git history on GitHub? Any changes ought to be linked to a pull request explaining why they were made. This could be an accidental side effect of fixing something else...

Resolving patch:
diff --git a/Bio/Phylo/NewickIO.py b/Bio/Phylo/NewickIO.py
--- a/Bio/Phylo/NewickIO.py
+++ b/Bio/Phylo/NewickIO.py
@@ -84,7 +84,7 @@ def _format_comment(text):
 
 def _get_comment(clade):
     try:
-        comment = clade.coment
+        comment = clade.comment
     except AttributeError:
         pass
     else:


Test patch: