johnomics / tapestry

Validate and edit small eukaryotic genome assemblies
MIT License
31 stars 2 forks source link

too many SQL variables #2

Closed aleksandrabliznina closed 5 years ago

aleksandrabliznina commented 5 years ago

Hi John,

Thank you for your tool! I am very excited about using it for my assembly, but always run into this problem:

Processing contigs: 0%| | 0/41 [00:00<?, ? contig/s]multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute cursor.execute(statement, parameters) sqlite3.OperationalError: too many SQL variables

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/apps/unit/LuscombeU/python/3.7.3/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/work/.apps/unit/LuscombeU/tapestry/0.9/tapestry/contig.py", line 48, in process_contig contig.process() File "/work/.apps/unit/LuscombeU/tapestry/0.9/tapestry/contig.py", line 138, in process self.left_connectors, self.right_connectors = self.get_connectors() File "/work/.apps/unit/LuscombeU/tapestry/0.9/tapestry/contig.py", line 307, in get_connectors left_connectors = self.get_region_connectors(0, 10000) File "/work/.apps/unit/LuscombeU/tapestry/0.9/tapestry/contig.py", line 282, in get_region_connectors for aln in self.alignments.connectors(self.name, region_start, region_end): File "/work/.apps/unit/LuscombeU/tapestry/0.9/tapestry/alignments.py", line 452, in connectors read_results = self.engine.connect().execute(stmt).fetchall() File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute return meth(self, multiparams, params) File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement distilled_params, File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context e, statement, parameters, cursor, context File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception util.raise_from_cause(sqlalchemy_exception, exc_info) File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 128, in reraise raise value.with_traceback(tb) File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/home/a/aleksandrabliznina/.local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) too many SQL variables [SQL: SELECT alignments.contig, alignments.ref_start, alignments.ref_end FROM alignments WHERE alignments."query" IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND alignments.contig != ? AND (alignments.alntype = ? OR alignments.alntype = ?)]

Please, see the attached file for more details!

slurm-5725678.out.txt

I do not clearly understand the problem. Is something wrong with my data? Genome size is around 65 Mb and I had to significantly reduce the read length (down to 1000) and depth (down to 30) parameters because the majority of my nanopore reads are much shorter.

Thanks! Looking forward to your reply!

Best regards, Sasha

johnomics commented 5 years ago

Hi Sasha,

Thank you very much for trying Tapestry - I'm sorry you're having difficulties. This is a problem with my database code, not your data. I'm trying to load too many reads at once, and will need to rewrite the code to load reads in batches. Unfortunately I'm away this week and it will take me some time to get this fixed - apologies - but I will get to it soon.

In the meantime, I would try reducing the depth to 10 and/or increasing the read length to 2000 or 5000. Tapestry may complain that you don't have enough coverage but it should still run and produce a report (if it doesn't, let me know). If you include 1000bp reads, you will be including a lot of reads from repeat regions that won't map uniquely, and they often don't tell you very much about the quality of the assembly. So you'll probably learn about the same amount from your report if you throw out these reads and just stick to the longer reads, even if your overall coverage is low.

Thanks John

aleksandrabliznina commented 5 years ago

Hi John,

Thank you for your reply and advice. I'll be waiting for the updates!

Meanwhile, I tried running tapestry with the depth 10 and the read length 5000. It looks like it successfully went through the step it got stuck at last time. But this time I ran into another problem with calculating ploidy estimates:

Dmitriis-MacBook-Pro:I69-3-4 aleksandra-bliznina$ weave -a I69-3-4.fa -r I69-2_GuppyFF_1000.fastq.gz -d 10 -l 5000 -t TTAGGG -w 1000 -o results-2 -c 4 Tapestry version 0.9.3 Dependencies minimap2 2.8-r672 /Users/aleksandra-bliznina/anaconda/bin/minimap2 samtools 1.7 /Users/aleksandra-bliznina/anaconda/bin/samtools

Welcome to Tapestry!

Assembly to validate I69-3-4.fa Reads to sample from I69-2_GuppyFF_1000.fastq.gz Coverage to sample 10 Minimum read length 5000 Telomere sequence(s) TTAGGG Ploidy window size 1000 Output directory results-2

2019-06-05 14:00:05 WARNING Output directory results-2 found, will use existing analysis files if present and up-to-date, but overwrite reports 2019-06-05 14:00:05 INFO Found results-2/assembly.fasta, will not overwrite 2019-06-05 14:00:05 INFO Loading genome assembly 2019-06-05 14:00:06 INFO Loaded 41 contigs from I69-3-4.fa 2019-06-05 14:00:06 INFO Will use existing results-2/reads.fastq.gz 2019-06-05 14:00:06 INFO Will use existing results-2/reads_assembly.bam 2019-06-05 14:00:06 INFO Will use existing results-2/reads_assembly.bam.bai 2019-06-05 14:00:06 INFO Will use existing results-2/contigs_assembly.bam 2019-06-05 14:00:06 INFO Will use existing results-2/contigs_assembly.bam.bai 2019-06-05 14:00:06 INFO Building alignments database results-2/alignments.db 2019-06-05 14:00:07 INFO Loading contig alignments into database 2019-06-05 14:00:12 INFO Loading read alignments into database 2019-06-05 14:00:43 INFO Finding neighbouring alignments 2019-06-05 14:43:42 INFO Processing 41 contigs Processing contigs: 0%| | 0/41 [00:00<?, ? contig/s]/Users/aleksandra-bliznina/anaconda/lib/python3.6/site-packages/sqlalchemy/sql/default_comparator.py:161: SAWarning: The IN-predicate on "alignments.query" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate. Consider alternative strategies for improved performance. 'strategies for improved performance.' % expr) Processing contigs: 63%|█████████████████████████████████████████████████████████████████████████████████▏ | 26/41 [08:36<05:22, 21.47s/ contig]/Users/aleksandra-bliznina/anaconda/lib/python3.6/site-packages/sqlalchemy/sql/default_comparator.py:161: SAWarning: The IN-predicate on "alignments.query" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate. Consider alternative strategies for improved performance. 'strategies for improved performance.' % expr) /Users/aleksandra-bliznina/anaconda/lib/python3.6/site-packages/sqlalchemy/sql/default_comparator.py:161: SAWarning: The IN-predicate on "alignments.query" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate. Consider alternative strategies for improved performance. 'strategies for improved performance.' % expr) 2019-06-05 14:54:23 INFO Calculating ploidy estimates Ploidy estimates: 0%| | 0/41 [00:00<?, ? contig/s]multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/Users/aleksandra-bliznina/anaconda/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/Users/aleksandra-bliznina/anaconda/lib/python3.6/site-packages/tapestry/contig.py", line 52, in get_ploidy contig.ploidys = contig.get_ploidys(median_depth) File "/Users/aleksandra-bliznina/anaconda/lib/python3.6/site-packages/tapestry/contig.py", line 252, in get_ploidys labels = model.fit_predict(depths) AttributeError: 'BayesianGaussianMixture' object has no attribute 'fit_predict' """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Users/aleksandra-bliznina/anaconda/bin/weave", line 45, in assembly = Assembly(args.assembly, args.reads, args.telomere, args.output, args.cores, args.depth, args.length, args.windowsize, args.noreadoutput) File "/Users/aleksandra-bliznina/anaconda/lib/python3.6/site-packages/tapestry/assembly.py", line 96, in init self.get_ploidys() File "/Users/aleksandra-bliznina/anaconda/lib/python3.6/site-packages/tapestry/assembly.py", line 286, in get_ploidys for contig in tapestry_tqdm(p.imap(fit_ploidy, self.contigs.values()), total=len(self.contigs), desc="Ploidy estimates"): File "/Users/aleksandra-bliznina/anaconda/lib/python3.6/site-packages/tqdm/_tqdm.py", line 1005, in iter for obj in iterable: File "/Users/aleksandra-bliznina/anaconda/lib/python3.6/multiprocessing/pool.py", line 699, in next raise value AttributeError: 'BayesianGaussianMixture' object has no attribute 'fit_predict'.

Please, have a look when you have time!

Thanks, Sasha

johnomics commented 5 years ago

Hi Sasha,

Sorry, my fault. Tapestry requires scikit-learn v0.20 or greater, but I haven't specified this constraint properly in the conda recipe. I will fix this soon, but in the meantime please update scikit-learn and run again ('conda update scikit-learn' should do it, but please make sure v0.20 or greater is installed).

Thanks John

aleksandrabliznina commented 5 years ago

Hi John,

I managed to run it and got a report! Thank you for staying in touch and helping with the problems. I'll be waiting for the updates!

Best regards, Sasha

johnomics commented 5 years ago

Excellent! Thanks for your patience. Please let me know if anything doesn't look right in the report or if there are any other features that would be helpful. I'll get to the SQL bug soon.

johnomics commented 5 years ago

Hi Sasha,

I've tried to fix the SQL issue, but I don't have a dataset to test it. If you have time, please could you try installing the latest commit from GitHub (instructions are in the README) and generating a report again with read length 1000 and depth 30, as you were trying before?

Many thanks John

aleksandrabliznina commented 5 years ago

Hi John,

I tried running tapestry (version after the last commit) with length 1000 and depth 30 and it worked. Thank you very much for your help!

I have a problem with the report. But I think I will just open a new issue.

Best regards, Sasha