You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble accessing/using FORMAT/INFO fields from vcf Records and the documentation isn't clear on how to be able to do anything with the data types returned via the API. Here's an example code snippet:
use rust_htslib::bcf::record::Record;
fn test_record(rec: Record) {
let i = rec.format(b"DP").integer().expect("Unable to convert to integer"); // has type BufferBacked<'_, Vec<&[i32]>, Buffer>
}
It's not clear that i can be used for any computation, and it especially seems like i cannot be coerced into a Vec<u32> in any way I can see. How can I actually do any computation with this sort of value? For example, suppose I wanted to add up the values in the vector of DP values in my vcf. How would I achieve that with these data types? Given that u32 implements Copy, ideally I'd like to be able to copy the wrapped value to an owned type and do something with that.
What's the reason behind wrapping these values in the BufferBacked type, and what is that type actually doing? There are warnings in the docs about keeping it in scope to handle some memory issues, but not much more on how to use these types.
The text was updated successfully, but these errors were encountered:
I'm having trouble accessing/using FORMAT/INFO fields from vcf Records and the documentation isn't clear on how to be able to do anything with the data types returned via the API. Here's an example code snippet:
use rust_htslib::bcf::record::Record;
fn test_record(rec: Record) {
let i = rec.format(b"DP").integer().expect("Unable to convert to integer"); // has type BufferBacked<'_, Vec<&[i32]>, Buffer>
}
It's not clear that i can be used for any computation, and it especially seems like i cannot be coerced into a Vec<u32> in any way I can see. How can I actually do any computation with this sort of value? For example, suppose I wanted to add up the values in the vector of DP values in my vcf. How would I achieve that with these data types? Given that u32 implements Copy, ideally I'd like to be able to copy the wrapped value to an owned type and do something with that.
What's the reason behind wrapping these values in the BufferBacked type, and what is that type actually doing? There are warnings in the docs about keeping it in scope to handle some memory issues, but not much more on how to use these types.
I found a way to access the value in BufferBacked.
Might be helpful:
letSome(u) = record.info(b"MQ").float().expect("Error accessing INFO MQ")else{todo!()};println!("{:#?}", u[0]);let v = record.format(b"DP").integer().expect("Error accessing FORMAT DP");println!("{:#?}", v[0]);
use std::str::from_utf8 to trans BufferedBackend to &str #350 (comment)
I'm having trouble accessing/using FORMAT/INFO fields from vcf
Record
s and the documentation isn't clear on how to be able to do anything with the data types returned via the API. Here's an example code snippet:It's not clear that
i
can be used for any computation, and it especially seems likei
cannot be coerced into aVec<u32>
in any way I can see. How can I actually do any computation with this sort of value? For example, suppose I wanted to add up the values in the vector ofDP
values in my vcf. How would I achieve that with these data types? Given thatu32
implementsCopy
, ideally I'd like to be able to copy the wrapped value to an owned type and do something with that.What's the reason behind wrapping these values in the
BufferBacked
type, and what is that type actually doing? There are warnings in the docs about keeping it in scope to handle some memory issues, but not much more on how to use these types.The text was updated successfully, but these errors were encountered: