Repository navigation
Refuse a junction or annotation table cut short - #374
Open
BenjaminDEMAILLE wants to merge 1 commit into
Open
BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
sjdbInfo.txt, sjdbList.out.tab, transcriptInfo.tab, exonInfo.tab, geneInfo.tab and exonGeTrInfo.tab must end with a newline and hold the rows their header (or sjdbInfo.txt) says. sjdbInfo.txt's junctions must fill the Genome after the chromosomes. sjdbList.out.tab is checked only when junctions are inserted, the one time STAR reads it. STAR reads most of these silently and maps or counts wrongly, or hangs: DIVERGENCE.md 1.9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #354 (truncated junction and annotation tables in the index).
Stacked on #357. The base is
fix/junction-index-safety; only the last commit is this PR.Problem
#357 checks the sizes of
Genome,SA,SAindexand the chromosome tables. The text tables were not covered:sjdbInfo.txt,exonInfo.taborgeneInfo.tabloaded, with a wrong last value (for example anexLenCumof20instead of200). Exit 0.sjdbList.out.tabandexonGeTrInfo.tabwere never read, so a short one went unnoticed. Exit 0.sjdbInfo.txtwas not checked against the Genome.Whole lines missing from
sjdbInfo.txt,transcriptInfo.tab,exonInfo.tabandgeneInfo.tabwere already refused by the row-count checks.What STAR does (2.7.11b source)
sjdbInfo.txt:Genome::loadSJDBreads the count, the overhang and the rows with>>and checks nothing (Genome_genomeLoad.cpp:487-519). Missing rows read as zeros.sjdbList.out.tab: read only when junctions are inserted at mapping (--sjdbGTFfile,--sjdbFileChrStartEnd,--twopassMode Basic) to reload the index's junctions (sjdbInsertJunctions.cpp:15-18).sjdbLoadFromStream.cppreads lines until EOF, with no count.transcriptInfo.tab: refused when a read fails, exit 105 (Transcriptome.cpp:51-56). A last line without its newline also fails: the last>>hits EOF.geneInfo.tab,exonInfo.tab,exonGeTrInfo.tab: read with no check (Transcriptome.cpp:18-29,62-75,78-97).--quantModeor STARsolo (Transcriptome.cpp:9).Change
read_index_table(src/index/io.rs): a table that does not end with a newline is refused, "is empty or its last line is cut: the index is damaged or was not fully copied". Used forsjdbInfo.txt,sjdbList.out.tab,transcriptInfo.tab,exonInfo.tab,geneInfo.tabandexonGeTrInfo.tab. Every one is written with a final newline by STAR and by rustar-aligner.read_sjdb_info_tab: the junctions,2*sjdbOverhang+1bytes each, have to fill the Genome after the chromosomes.check_sjdb_list: when junctions are inserted,sjdbList.out.tabhas to hold as many junctions assjdbInfo.txt. Without insertion it is not read, as in STAR.check_exon_ge_tr_info:exonGeTrInfo.tab, when present, has to hold the rows its header says. rustar-aligner rebuilds this table from the others, but STAR counts genes from it, so a short one gives other numbers in STAR on the same index.sjdb_insert(params)factors out thesjdbInsert.yestest thatcheck_genome_versionalready had.Where STAR exits 0 this is a divergence:
DIVERGENCE.md§1.9, needs maintainer sign-off.Measured against STAR 2.7.11b
Synthetic genome of 60 kb, GTF of 20 genes, 40 transcripts, 100 exons, 60 junctions,
--sjdbOverhang 99; 400 spliced 100 bp reads. Each tool built its own index; all six tables are byte-identical between the two. STAR is the Linux 2.7.11b build for--quantMode. Mapping was plain forsjdbInfo.txt, with--sjdbFileChrStartEnd(one new junction) forsjdbList.out.tab, and with--quantMode TranscriptomeSAM GeneCountsfor the transcript tables. "line" drops the last line, "mid" the last 3 bytes, "10 rows" the last 10 lines.Intact index, both tools: rc 0, 400 unique, 40 junctions in
SJ.out.tab, same SAM records, 400 reads inAligned.toTranscriptome.out.bam, sameReadsPerGene.out.tab.sjdbInfo.txtlinesjdbInfo.txtmidsjdbInfo.txt10 rowssjdbInfo.txtoverhang 99 → 98 in headersjdbList.out.tabline, insertionsjdbList.out.tabmid, insertionsjdbList.out.tabline, no insertiontranscriptInfo.tabline / midexonInfo.tablineexonInfo.tabmidexonInfo.tab10 rowsgeneInfo.tablineReadsPerGene.out.tabgeneInfo.tabmidexonGeTrInfo.tabline / midexonGeTrInfo.tab10 rowsN_noFeatureinstead of 0A cut of 2 bytes (the newline and one digit) gives the same "after" row as "mid" for all six tables.
Tests
tests/index_load.rs, on an index built from a one-transcript GTF:table_with_a_cut_last_line_is_refused: each of the six tables loses 2 bytes, mapping with junction insertion fails naming the file; the restored index maps.short_sjdb_list_is_refused_when_junctions_are_inserted: one junction of two left; plain mapping succeeds,--twopassMode Basicfails.sjdb_info_that_disagrees_with_the_genome_is_refused: overhang 50 → 49 in the header.All three fail without the
src/change and pass with it.read_sjdb_info_tab_roundtripnow gives its genome the junction bytes.cargo test --release,cargo clippy --all-targets -- -D warningsandcargo fmt --checkare clean on macOS.Not checked
--quantModeor STARsolo, where STAR does not read them. That was already so for missing lines before this PR.Velocytowith a damaged table were not run.sjdbList.out.tabwas not traced.🤖 Generated with Claude Code