Repository: biopython/biopython

Issue:
"__getitem__" called by mistake on "_codons2re" function
Hello,

While analyzing biopython on SonarCloud I saw what looks like two similar errors in `Bio/codonalign/__init__.py`: [here](https://github.com/biopython/biopython/blob/05107f5cfd1f8d67dbc4d472268618f2b6d93bc2/Bio/codonalign/__init__.py#L609) and [here](https://github.com/biopython/biopython/blob/05107f5cfd1f8d67dbc4d472268618f2b6d93bc2/Bio/codonalign/__init__.py#L675):

<img width="1613" alt="Screenshot 2020-10-03 at 16 08 21" src="https://user-images.githubusercontent.com/40498978/94993700-27bd9780-0593-11eb-9d5c-3c5f9cacd887.png">


<img width="1613" alt="Screenshot 2020-10-03 at 16 10 53" src="https://user-images.githubusercontent.com/40498978/94993709-3015d280-0593-11eb-98b7-b479a44c2852.png">



You can see the corresponding issue in SonarCloud [here](https://sonarcloud.io/project/issues?id=nicolas-harraudeau-sonarsource_biopython&issues=AXTqE7kmA4gH5cbKom2x&open=AXTqE7kmA4gH5cbKom2x) and [here](https://sonarcloud.io/project/issues?id=nicolas-harraudeau-sonarsource_biopython&issues=AXTqE7kmA4gH5cbKom2y&open=AXTqE7kmA4gH5cbKom2y).

The problem is that `_codons2re` [is a function](https://github.com/biopython/biopython/blob/05107f5cfd1f8d67dbc4d472268618f2b6d93bc2/Bio/codonalign/__init__.py#L203), thus it is not subscriptable, i.e. you can't call `__getitem__` on it. The developer probably meant to use parentheses instead of square brackets [as it is the case here](https://github.com/biopython/biopython/blob/05107f5cfd1f8d67dbc4d472268618f2b6d93bc2/Bio/codonalign/__init__.py#L242-L243). Reaching this code will raise the following exception:
```
TypeError: 'function' object is not subscriptable
```

In case you want to scan biopython on SonarCloud [you can use a configuration similar to this one](https://github.com/nicolas-harraudeau-sonarsource/biopython/commit/9952e28e9c411a626620a78993fd9af8d24dd9ab) when you enable automatic analysis.


Discussion:
Problem dates back 7 years, 8df9bcae42eda5c8f1bd574fa49f3e3dddffddd7 - looks like no one triggered this in all that time?

Pretty sure it should just be round brackets - do you agree @zruan ?

Resolving patch:
diff --git a/Bio/codonalign/__init__.py b/Bio/codonalign/__init__.py
--- a/Bio/codonalign/__init__.py
+++ b/Bio/codonalign/__init__.py
@@ -187,7 +187,7 @@ def build(
                 pair[1],
                 corr_span,
                 gap_char=gap_char,
-                complete_protein=False,
+                complete_protein=complete_protein,
                 codon_table=codon_table,
                 max_score=max_score,
             )
@@ -606,7 +606,7 @@ def _get_codon_rec(
             elif complete_protein and aa_num == 0:
                 this_codon = nucl_seq[span[0] : span[0] + 3]
                 if not re.search(
-                    _codons2re[codon_table.start_codons], this_codon.upper()
+                    _codons2re(codon_table.start_codons), str(this_codon.upper())
                 ):
                     max_score -= 1
                     warnings.warn(
@@ -672,7 +672,7 @@ def _get_codon_rec(
             elif complete_protein and aa_num == 0:
                 this_codon = nucl_seq[rf_table[0] : rf_table[0] + 3]
                 if not re.search(
-                    _codons2re[codon_table.start_codons], this_codon.upper()
+                    _codons2re(codon_table.start_codons), str(this_codon.upper())
                 ):
                     max_score -= 1
                     warnings.warn(


Test patch:
diff --git a/Tests/test_codonalign.py b/Tests/test_codonalign.py
--- a/Tests/test_codonalign.py
+++ b/Tests/test_codonalign.py
@@ -280,6 +280,7 @@ def test_build(self):
         codon_aln3 = codonalign.build(
             self.aln3, self.seqlist3, codon_table=self.codontable3
         )
+        codon_aln4 = codonalign.build(self.aln1, self.seqlist1, complete_protein=True)
 
 
 class Test_dn_ds(unittest.TestCase):