Skip to content

BIGSI exact search always returns name of first sample #57

Description

@tabwalsh

If a query sequence is found with exact search, BIGSI returns the ID of the first sample, regardless of which ones have actually matched.

Example

From within bigsi/example-data/ directory of the BIGSI package,
construct a BIGSI from the files kmers.ctx and query.fasta:

mccortex 31 build -k 31 -s query --seq query.fasta query.ctx
echo "{h: 3, k: 31, m: 25000000, storage-config: {filename: test.bigsi,"\
     " flag: c}, storage-engine: berkeleydb}" > test.yml
bigsi bloom -c test.yml query.ctx query.bloom
bigsi bloom -c test.yml kmers.ctx kmers.bloom
echo -e "kmers.bloom\tkmers\nquery.bloom\tquery" > test.tsv
bigsi build -c test.yml --from_file test.tsv

Then generate a query sequence from the first 32 nucleotides of the
first sequence in query.fasta (i.e. CGGCGAGGAAGCGTTAAATCTCTTTCTGACGC):

qseq=$(grep -vm1 ">" query.fasta | head -c 32)

This shouldn't match any sequence in kmers.ctx, since
it contains only 31-mers. But when we search for this sequence
in our database, it reports a hit in the kmers sample.

bigsi search -c test.yml $qseq
{
    "query": "CGGCGAGGAAGCGTTAAATCTCTTTCTGACGC",
    "threshold": 1.0,
    "results": [
        {
            "percent_kmers_found": 100.0,
            "num_kmers": 2,
            "num_kmers_found": 2,
            "sample_name": "kmers"
        }
    ],
    "citation": "http://dx.doi.org/10.1038/s41587-018-0010-1"
}

Searching with an inexact filter reports the correct result:

bigsi search -c test.yml -t 0.9 $qseq
{
    "query": "CGGCGAGGAAGCGTTAAATCTCTTTCTGACGC",
    "threshold": 0.9,
    "results": [
        {
            "percent_kmers_found": 100.0,
            "num_kmers": 2,
            "num_kmers_found": 2,
            "sample_name": "query"
        }
    ],
    "citation": "http://dx.doi.org/10.1038/s41587-018-0010-1"
}

I think this may be caused by the exact filter checking for matching samples in the packed bit array, and could be fixed by unpacking the bit array before checking for matches. If need be, I'd be happy to submit a fix via a pull request.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions