Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/alignment length #59

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: derive insert length from inserted alignment, not the annotation
  • Loading branch information
rneher committed Mar 20, 2024
commit 4cf1cd472087814dccc724aa6d4388b8a058394b
10 changes: 6 additions & 4 deletions scripts/align_for_tree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from Bio import SeqIO
from Bio import SeqIO, AlignIO
from Bio.SeqRecord import SeqRecord
import shutil
import argparse
Expand All @@ -8,10 +8,12 @@ def alignfortree(realign, align, reference, newoutput, build):
if build != "genome":
shutil.copy(realign, newoutput)
else:
realigned = {s.id:s for s in SeqIO.parse(realign, "fasta")}
realigned_aln = AlignIO.read(realign, 'fasta')
insert_length = realigned_aln.get_alignment_length()
realigned = {s.id:s for s in realigned_aln}
original = SeqIO.parse(align, "fasta")
ref = SeqIO.read(reference, "genbank")

for feature in ref.features:
if feature.type =='gene' or feature.type=='CDS':
a =str((list(feature.qualifiers.items())[0])[-1])[2:-2]
Expand All @@ -22,7 +24,7 @@ def alignfortree(realign, align, reference, newoutput, build):
for record_original in original:
sequence_to_insert = realigned.get(record_original.id, None)
if sequence_to_insert is None:
sequence_to_insert = '-' * (endofgene - startofgene)
sequence_to_insert = '-' * insert_length
else:
sequence_to_insert = sequence_to_insert.seq

Expand Down