Skip to content
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

BCF header records #76

Merged
merged 8 commits into from May 15, 2018

Conversation

holtgrewe
Copy link
Contributor

This works but I'm unsure about the design being right.

@johanneskoester what do you think?

@@ -240,6 +257,54 @@ impl HeaderView {
(*(*self.inner).id[htslib::BCF_DT_SAMPLE as usize].offset(*id as isize)).key) };
key.to_bytes().to_vec()
}

/// Return structured `HeaderRecord`s.
pub fn header_records(&self) -> Vec<HeaderRecord> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would return a HashMap here, which assigns keys to HeaderRecord.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that will be enough. Rust's HashMap type is not insertion order (similar to the dict in Python <3.6). IMO we need to guarantee that (1) insertion order == order in BCF file and (2) vice versa. This is in particularly important for roundtrip processing of VCF files.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. And moreover there might be duplicate keys I think. Returning a Vector is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, so should I just rebase or perform any changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, resolving the merge conflicts now FWIW, would have to be done anyway.

/// A header record.
pub enum HeaderRecord {
/// A `FILTER` header record.
Filter { key: String, key_value_pairs: Vec<(String, String)> },
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these should be <type> {key: String, values: HashMap<String, String>}, except for Generic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, this should be LinearMap. By that, insertion order is preseved. https://docs.rs/linear-map

@holtgrewe
Copy link
Contributor Author

🎉 @johanneskoester The test runs through, the code compiles and is properly formatted. Please advise on any further need for change.

@holtgrewe
Copy link
Contributor Author

@johanneskoester ping

Copy link
Contributor

@johanneskoester johanneskoester left a comment

Choose a reason for hiding this comment

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

Sorry, I failed to submit the review. One final change requested below.

/// A `FILTER` header record.
Filter {
key: String,
key_value_pairs: Vec<(String, String)>,
Copy link
Contributor

Choose a reason for hiding this comment

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

In here, I think a linearmap would be nice. Sorry for the confusion. And I would rename the second field into values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, did so, let's see what the CI build says.

@holtgrewe
Copy link
Contributor Author

@johanneskoester Well, this runs through in principle but doctests now also fail on stable... Otherwise, I incorporated your changes. What now?

@johanneskoester
Copy link
Contributor

@holtgrewe it should be sufficient to update the bindgen dependency to 0.36 in order to fix that problem.

Cargo.toml Outdated
@@ -35,4 +36,4 @@ pretty_assertions = "0.5.1"

[build-dependencies]
fs-utils = "1.0"
bindgen = "0.35.0"
bindgen = "0.36.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Without the trailing zero, just 0.36? Then we automatically get patch releases.

Copy link
Contributor

@johanneskoester johanneskoester left a comment

Choose a reason for hiding this comment

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

Thanks a lot!!

@holtgrewe
Copy link
Contributor Author

@johanneskoester No it's not. And now?

@johanneskoester
Copy link
Contributor

This is either a bug in rust or a behavior change in rust and a bug in rust-bindgen. I have created an issue: rust-lang/rust-bindgen#1313

@johanneskoester
Copy link
Contributor

Can you update to the latest master of rust-htslib? I have temporarily pinned rust to 1.25

@holtgrewe
Copy link
Contributor Author

@johanneskoester OK, let's see if the build runs through now.

@johanneskoester johanneskoester changed the title WIP: Starting with BCF header records BCF header records May 15, 2018
@johanneskoester johanneskoester merged commit 8a74898 into rust-bio:master May 15, 2018
@johanneskoester
Copy link
Contributor

Yay! Thanks a lot!

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.

None yet

2 participants