-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IO] Is there a neat way to pass only selected fields to SAM output? #2436
Comments
Hi tobias, so if I understand you correctly, you want to switch between record-types (one mapped, one unmapped) in the output? I don't know if I caught your use case, but do you want to do: seqan3::sam_file_output<...> out{"./some_path"};
// write out a full record as you already do (field order shouldn't matter)
out.emplace_back(...);
// we just provide the id, everything else is default
using unmapped_read_record = seqan3::sam_record<seqan3::type_list<std::string>, seqan3::fields<seqan3::field::id>>;
unmapped_read_record unmapped{"READ 1"};
out.push_back(unmapped); (UNTESTED, I still need to compile it :)) We are currently working on it to make the customisation via those fields obsolete. seqan3::sam_file_output out{"./some_path"}; // no template arguments anymore, as they are only needed for emplacing the data
// note: you don't specify ANY fields anymore.
seqan3::sam_record record{.id = "read1"}; // other fields have sensible default types and values
record.id = "read1"; // or later as member assignment
recod.id(); // to access the data.
out.push_back(std::move(record)); // only set field read1 |
Hey Marcel, thanks for your response! Thus, the new planned solution sounds way more comfortable and would definitively be easier to use. I actually thought about asking whether a removal of the template arguments would be possible, but I wouldn't dare as I expect it to be a bunch of (structural) changes. I am really looking forward for this to be finished! |
Hey, thanks again for your answer, it compiled and worked as you proposed. Closed this thread, as the provided answer works. |
(Reopened, as I think we should add documentation for this use case.) |
Platform
Question
Hey all,
I am struggling a bit with properly writing unmapped reads to my output alignment files (which is a common feature I would like to have integrated into my software).
I understand that I can write records using
emplace_back(...)
and specifying all fields. I also know that it is in principle possible to provide less arguments to this function as long as they are not required. So, ifseqan3::field::id
was the first field specified for the sam output, I could callemplace_back("read1")
which would set the ID only and leave all other fields unset. However, there is no way to do the same if the id was the last element in the field list, so if you for example have (minimal example):it is no longer possible to create an entry having
seqan3::field::id
set only. Even when setting all other fields manually to default values, SeqAn would throw an error when trying to setseqan3::field::ref_id
to "" or "*" as it is not contained in the list of references.This behavior currently makes it complicated for me to have mixed files of mapped and unmapped reads, where in the latter case I can't provide a valid ref_id. Only workaround for me is currently to change the order of fields, but I am afraid this could in future lead to incompatibility if I need to mix even more combinations of (un-)reported fields.
Thus, my question is if I have overseen a (neat) way to fill the same
seqan3::sam_file_output
object with entries using different selections of fields?If no, it would be great if there was a possibility to have some function that allows to speficy the fields to set, e.g. something like this:
sam_out.emplace_back_selected<seqan3::fields<seqan3::field::id>>("Read 1");
which would be valid as long as
seqan3::field::id
is part of the sam file output object.Second option, there would be something like an unset value (or similar) to each of the fields that can be used to set fields that are not available to default value and at the same time are not caught by validation steps as, for example, with the reference ID:
sam_out.emplace_back(seqan3::field::ref_id::unset, "Read 1");
The text was updated successfully, but these errors were encountered: