<div dir="ltr"><div dir="ltr">You should avoid setting private attributes, the AlignIO function accepts and alphabet argument:<div><br></div><div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><span style="color:rgb(175,0,219)">from</span> Bio <span style="color:rgb(175,0,219)">import</span> AlignIO</div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><span style="color:rgb(175,0,219)">from</span> Bio.Alphabet <span style="color:rgb(175,0,219)">import</span> ProteinAlphabet<br></div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap">align = AlignIO.read(<span style="color:rgb(163,21,21)">'samples/cas9align.fasta'</span>, <span style="color:rgb(163,21,21)">'fasta'</span>)</div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap">align._alphabet = ProteinAlphabet()</div></div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><br></div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap">becomes:</div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><br></div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><div><span style="color:rgb(175,0,219)">from</span> Bio <span style="color:rgb(175,0,219)">import</span> AlignIO</div><div><span style="color:rgb(175,0,219)">from</span> Bio.Alphabet <span style="color:rgb(175,0,219)">import</span> ProteinAlphabet<br></div><div></div><div>align = AlignIO.read(<span style="color:rgb(163,21,21)">'samples/cas9align.fasta'</span>, <span style="color:rgb(163,21,21)">'fasta', </span>alphabet=ProteinAlphabet())</div></div><br>Also I would suggest using the generic protein instance as per the tutorial examples, which could make the planned alphabet simplification/removal this year easier:<div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><br></div><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><div><span style="color:rgb(175,0,219)">from</span> Bio <span style="color:rgb(175,0,219)">import</span> AlignIO</div><div><span style="color:rgb(175,0,219)">from</span> Bio.Alphabet <span style="color:rgb(175,0,219)">import</span> generic_protein<br></div><div></div></div><div style=""><div style="color:rgb(0,0,0);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><div>align = AlignIO.read(<span style="color:rgb(163,21,21)">'samples/cas9align.fasta'</span>, <span style="color:rgb(163,21,21)">'fasta', </span>alphabet=generic_protein)</div></div><div style=""><br></div><div style="">If that alone does not solve it, could you share the test FASTA file or reproduce this with one of the examples included with Biopython?</div><div style=""><br></div>Regards,</div><div style=""><br>Peter</div><div style=""><br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 21, 2020 at 11:02 PM Sebastian Bassi <<a href="mailto:sbassi@gmail.com">sbassi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I have a code that used to work I think in 1.52 or so.<div>This is the code I am testing now in 1.76:</div><div><br></div><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:monospace,Menlo,Monaco,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(175,0,219)">from</span> Bio <span style="color:rgb(175,0,219)">import</span> AlignIO</div><div><span style="color:rgb(175,0,219)">from</span> Bio.Align.AlignInfo <span style="color:rgb(175,0,219)">import</span> SummaryInfo</div><div><span style="color:rgb(175,0,219)">from</span> Bio.Alphabet <span style="color:rgb(175,0,219)">import</span> ProteinAlphabet</div><br><div>align = AlignIO.read(<span style="color:rgb(163,21,21)">'samples/cas9align.fasta'</span>, <span style="color:rgb(163,21,21)">'fasta'</span>)</div><div>align._alphabet = ProteinAlphabet()</div><div>summary = SummaryInfo(align)</div><div>summary.pos_specific_score_matrix()</div></div></div><div><br></div><div>I get <br></div><div><br></div><div><pre style="margin-bottom:0px;margin-top:0px;display:inline;color:rgb(33,33,33);font-size:14px"><a href="https://localhost:8080/#" target="_blank">/usr/local/lib/python3.6/dist-packages/Bio/Align/AlignInfo.py</a> in _guess_consensus_alphabet(self, ambiguous)
<span style="font-weight:bold"> 196</span> if not isinstance(alt, a.__class__):
<span style="font-weight:bold"> 197</span> raise ValueError("Alignment contains a sequence with \
--> 198 an incompatible alphabet.")
<span style="font-weight:bold"> 199</span>
<span style="font-weight:bold"> 200</span> # Check the ambiguous character we are going to use in the consensus
</pre><pre style="margin-bottom:0px;margin-top:0px;display:inline;color:rgb(33,33,33);font-size:14px">ValueError: Alignment contains a sequence wit an incompatible alphabet.</pre><br></div><div><br></div><div>The alignment alphabet is protein, so I don't know what is wrong with it.</div><div>This is the alignment file I am using:</div><div><a href="https://github.com/Serulab/Py4Bio/blob/master/samples/cas9align.fasta" target="_blank">https://github.com/Serulab/Py4Bio/blob/master/samples/cas9align.fasta</a><br></div><div><br></div><div>I will appreciate any help.</div><div><br></div><div>Best,</div><div>SB</div><div><br></div><div><br></div><div><br></div></div>
_______________________________________________<br>
Biopython mailing list - <a href="mailto:Biopython@mailman.open-bio.org" target="_blank">Biopython@mailman.open-bio.org</a><br>
<a href="https://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer" target="_blank">https://mailman.open-bio.org/mailman/listinfo/biopython</a></blockquote></div></div>