Skip to content

[FEAT] Option to ignore blanks before ids when reading FastA-Files - #2770

Merged
smehringer merged 2 commits into
seqan:masterfrom
SGSSGene:feat/remove_blank_before_id
Apr 27, 2022
Merged

[FEAT] Option to ignore blanks before ids when reading FastA-Files#2770
smehringer merged 2 commits into
seqan:masterfrom
SGSSGene:feat/remove_blank_before_id

Conversation

@SGSSGene

@SGSSGene SGSSGene commented Aug 23, 2021

Copy link
Copy Markdown
Contributor

A simple roundtrip through seqan3 (reading and writing a fasta file) should not introduce any changes with the default options

auto fout = seqan3::sequence_file_input{std::istringstream{input}, seqan3::format_fasta{}} |
                  seqan3::sequence_file_output{std::ostringstream{}, seqan3::format_fasta{}};

The PR #2769 fixes the forced introduction of spaces before the sequence ids.
This PR fixes the removal of whitespaces when reading a fasta file.
This changes the default behavior. To achieve the old behavior a new flag is introduced:
fin.options.fasta_ignore_blank_before_id which is by default true.

Example:
File

> seq1
ACTG

seqan3 now: id="seq1"
some others: id=" seq1"

@vercel

vercel Bot commented Aug 23, 2021

Copy link
Copy Markdown

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/seqan/seqan3/Fugjpfm7cJd6WKCsQNp6ZVmKY2H4
✅ Preview: https://seqan3-git-fork-sgssgene-feat-removeblankbeforeid-seqan.vercel.app

@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch from fabca48 to fb2ae2a Compare August 23, 2021 11:15
@SGSSGene
SGSSGene requested review from a team and MitraDarja and removed request for a team August 23, 2021 11:15
@codecov

codecov Bot commented Aug 23, 2021

Copy link
Copy Markdown

Codecov Report

Merging #2770 (048469c) into master (b4984bc) will decrease coverage by 0.03%.
The diff coverage is 72.22%.

@@            Coverage Diff             @@
##           master    #2770      +/-   ##
==========================================
- Coverage   98.22%   98.19%   -0.04%     
==========================================
  Files         267      267              
  Lines       11511    11521      +10     
==========================================
+ Hits        11307    11313       +6     
- Misses        204      208       +4     
Impacted Files Coverage Δ
include/seqan3/io/sequence_file/format_fasta.hpp 89.38% <72.22%> (-2.86%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5c63f9...048469c. Read the comment docs.

@MitraDarja MitraDarja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one minor thing. :)

Comment thread test/unit/io/sequence_file/sequence_file_integration_test.cpp Outdated
@eseiler
eseiler requested a review from marehr August 25, 2021 15:37
@smehringer

Copy link
Copy Markdown
Member

Core Meeting 25.10.2021 - The default should still be "blanks are stripped" because usually blanks are usually ignored. the option is still useful to allow for a "perfect roundtrip".

@SGSSGene

Copy link
Copy Markdown
Contributor Author

I will unchange default to 'true'

@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch from fb2ae2a to fd3d739 Compare October 26, 2021 08:37
@SGSSGene
SGSSGene changed the base branch from master to release-3.1.0 October 26, 2021 08:39
@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch 4 times, most recently from c42ce88 to fe9d3c0 Compare October 27, 2021 07:57
{}
if (options.fasta_ignore_blanks_before_id)
{
for (; (it != e) && (is_id || is_blank)(*it); ++it)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you do something like

auto const is_id = options.fasta_ignore_blanks_before_id ? (is_char<'>'> || is_char<';'> || is_blank) : (is_char<'>'> || is_char<';'>);

in line 178

@SGSSGene SGSSGene Oct 27, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is not possible. Line 180 checks if the character is a > or ;

        if (!is_id(*begin(stream_view)))

That line would be wrong if it included a whitespace.

I'm just noticing the parsing of ID is not correct either way.
Currently >>>>>>>> TEST would be parsed as TEST.
and with my changes: > > >>> > > > TEST would also be parsed as TEST

I am assuming that is also not what we want?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created a new PR to fix this: #2869

@eseiler
eseiler changed the base branch from release-3.1.0 to master November 10, 2021 10:58
@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch from fe9d3c0 to f6207ef Compare November 30, 2021 15:54
@smehringer
smehringer requested review from a team and smehringer and removed request for a team and marehr December 6, 2021 10:27
@eseiler

eseiler commented Dec 8, 2021

Copy link
Copy Markdown
Member

#2769 is merged, so this can be rebased? (This PR was marked blocked by #2769)

@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch from f6207ef to 20f708d Compare January 12, 2022 12:29
@SGSSGene

Copy link
Copy Markdown
Contributor Author

#2769 is merged, so this can be rebased? (This PR was marked blocked by #2769)

Its blocked by #2869

@SGSSGene

Copy link
Copy Markdown
Contributor Author

#2769 is merged, so this can be rebased? (This PR was marked blocked by #2769)

Its blocked by #2869

No, this is not blocked by #2869, this can be independently be merged :-)

@SGSSGene
SGSSGene requested a review from eseiler January 12, 2022 12:48
@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch 2 times, most recently from a8fbeaf to 1983b08 Compare February 9, 2022 11:06

@eseiler eseiler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should merge #2869 first, I want to have another look at the predicates afterwards :)

@eseiler
eseiler force-pushed the feat/remove_blank_before_id branch from 1983b08 to f886ce0 Compare March 23, 2022 15:13

@eseiler eseiler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't find an elegant way to avoid code duplication

@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch from f886ce0 to 1983b08 Compare March 28, 2022 08:32
@eseiler
eseiler force-pushed the feat/remove_blank_before_id branch from 1983b08 to f886ce0 Compare March 28, 2022 08:36
@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch 3 times, most recently from 9a317f9 to ea2de7b Compare March 29, 2022 08:41

@smehringer smehringer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although there is no change in behavior, I would add a short changelog entry for this new feature

Comment on lines +64 to +59
">TEST 1\n"
"ACGT\n"
"> Test2\n"
"AGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGNAGGCTGN\n"
"> Test3\n"
"GGAGTATAATATATATATATATAT\n"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be even more understandable if you use this as input AND output string. So one does not have to compare input and output_comp when looking at it but directly notices the "perfect roundtrip".

Or do you explicitly want to show that spaces in the sequence are still removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will adjust. 👍

@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch from ea2de7b to 98c7471 Compare March 31, 2022 09:48
@SGSSGene
SGSSGene requested a review from smehringer March 31, 2022 09:50
@smehringer

Copy link
Copy Markdown
Member

there is a conflict. Please rebase

@SGSSGene
SGSSGene force-pushed the feat/remove_blank_before_id branch from 98c7471 to 048469c Compare April 12, 2022 13:07
@smehringer
smehringer merged commit 79b6467 into seqan:master Apr 27, 2022
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.

4 participants