Skip to content

Keep SEQid to a single field in the output tables - #42

Closed
alexlancaster wants to merge 1 commit into
whitehead:masterfrom
ssiddhantsharma:tsv-safe-seqid
Closed

Keep SEQid to a single field in the output tables#42
alexlancaster wants to merge 1 commit into
whitehead:masterfrom
ssiddhantsharma:tsv-safe-seqid

Conversation

@alexlancaster

Copy link
Copy Markdown
Contributor

I've rebased #41 against master.

Here is @ssiddhantsharma original comment:

Sequence names are copied verbatim from the FASTA header into the SEQid column of both output tables, which are tab-delimited. A tab inside a header therefore split SEQid across several fields and shifted every column after it. Nothing failed: the header row kept its 41 columns while affected data rows gained one field per tab, so anything reading the table by column index silently read values from the wrong columns. MitoCarta and several other curated FASTA distributions ship tab-separated headers, which is how this is usually met.

A related inconsistency came from fastareader.nextfasta(), which discarded the result of its trim(). The first record of a file takes its name from hasmorefastas(), which does trim, while later records took it from nextfasta(), which did not. A file whose headers carried trailing whitespace could therefore produce a different column count for its first record than for the rest.

Map tabs, newlines and other control characters in the name to spaces and trim it, so SEQid is always exactly one field, and assign the trimmed name in nextfasta(). Names without control characters or surrounding whitespace are unchanged, embedded spaces included, so the MOT3 golden output is byte-identical.

cli/tests/test_seqid_field.sh covers a tab inside a header, agreement between the tab- and space-separated forms of the same header, trailing tabs and spaces across a multi-record file, the per-residue table under -p, and that ordinary names are left alone. Five of its six checks fail without this change. Wired into cli.yml alongside the MOT3 and input-validation tests.

Sequence names are copied verbatim from the FASTA header into the SEQid column of
both output tables, which are tab-delimited. A tab inside a header therefore split
SEQid across several fields and shifted every column after it. Nothing failed: the
header row kept its 41 columns while affected data rows gained one field per tab, so
anything reading the table by column index silently read values from the wrong
columns. MitoCarta and several other curated FASTA distributions ship tab-separated
headers, which is how this is usually met.

A related inconsistency came from fastareader.nextfasta(), which discarded the result
of its trim(). The first record of a file takes its name from hasmorefastas(), which
does trim, while later records took it from nextfasta(), which did not. A file whose
headers carried trailing whitespace could therefore produce a different column count
for its first record than for the rest.

Map tabs, newlines and other control characters in the name to spaces and trim it, so
SEQid is always exactly one field, and assign the trimmed name in nextfasta(). Names
without control characters or surrounding whitespace are unchanged, embedded spaces
included, so the MOT3 golden output is byte-identical.

cli/tests/test_seqid_field.sh covers a tab inside a header, agreement between the
tab- and space-separated forms of the same header, trailing tabs and spaces across a
multi-record file, the per-residue table under -p, and that ordinary names are left
alone. Five of its six checks fail without this change. Wired into cli.yml alongside
the MOT3 and input-validation tests.
@alexlancaster alexlancaster self-assigned this Sep 2, 2026
@ssiddhantsharma ssiddhantsharma closed this by deleting the head repository Sep 2, 2026
@alexlancaster

Copy link
Copy Markdown
Contributor Author

hi @ssiddhantsharma looks like you deleted your plaac fork? are you OK with me still testing/merging this? we really appreciate your contributions!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants