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

Speed up overlap lookup in CDS stage #493

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
28 changes: 21 additions & 7 deletions bin/prokka
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,17 @@ if ($tools{'minced'}->{HAVE}) {
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
# CDS

# Create a hash of RNA lists, grouped by seqid to speed up lookups.
my %rnabyseq;
for my $rna (@allrna) {
my @a = ();
$rnabyseq{$rna->seq_id} = \@a;
}
for my $rna (@allrna) {
my $a = $rnabyseq{$rna->seq_id};
push @$a, $rna;
}

msg("Predicting coding sequences");
my $totalbp = sum( map { $seq{$_}{DNA}->length } @seq);
my $prodigal_mode = ($totalbp >= 100000 && !$metagenome) ? 'single' : 'meta';
Expand Down Expand Up @@ -744,15 +755,18 @@ while (<$PRODIGAL>) {
}
);
my $overlap;
for my $rna (@allrna) {
# same contig, overlapping (could check same strand too? not sure)
if ($rna->seq_id eq $sid and $cds->overlaps($rna)) {
$overlap = $rna;
last;
}
if (!$cds_rna_olap and exists($rnabyseq{$sid})) {
my $seqrna = $rnabyseq{$sid};
for my $rna (@$seqrna) {
# same contig, overlapping (could check same strand too? not sure)
if ($rna->seq_id eq $sid and $cds->overlaps($rna)) {
$overlap = $rna;
last;
}
}
}
# mitochondria are highly packed, so don't exclude as CDS/tRNA often overlap.
if ($overlap and ! $cds_rna_olap) {
if ($overlap) {
my $type = $overlap->primary_tag;
msg("Excluding CDS which overlaps existing RNA ($type) at $sid:$1..$2 on $3 strand");
}
Expand Down