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

[hail] Fix unnecessarily long exported genotype fields in export_vcf #5298

Merged
merged 5 commits into from
Feb 12, 2019

Conversation

tpoterba
Copy link
Contributor

@tpoterba tpoterba commented Feb 8, 2019

No description provided.

@tpoterba
Copy link
Contributor Author

tpoterba commented Feb 8, 2019

While a filtered entry was correctly being exported as ./., an entry with all missing fields was emitted as ./.:.:.:.:.:.. This will truncate missing fields as intended.

jigold
jigold previously requested changes Feb 11, 2019
Copy link
Collaborator

@jigold jigold left a comment

Choose a reason for hiding this comment

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

I didn't realize that you could truncate fields and it would still be a valid VCF. I found this in the spec Trailing fields can be dropped (with the exception of the GT field, which should always be present if specified in the FORMAT field).

I think your code should look at whether the first field is of type call or not. Otherwise it should be a .

def emitGenotype(sb: StringBuilder, formatFieldOrder: Array[Int], tg: PStruct, m: Region, offset: Long, missingnessArray: Array[Boolean]) {
var i = 0
while (i < formatFieldOrder.length) {
missingnessArray(i) = tg.isFieldDefined(m, offset, formatFieldOrder(i))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a !tg.isFieldDefined. Then it will be true if missing which matches the name of the array. Otherwise, it makes my head hurt a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to fieldDefined.

@tpoterba
Copy link
Contributor Author

I think your code should look at whether the first field is of type call or not. Otherwise it should be a .

My change preserves all export semantics, aside from dropping trailing fields. I do believe that it's currently quite broken in the case you describe (GT is not a field at all) but want to have that discussion in a separate PR.

@tpoterba tpoterba changed the title Fix unnecessarily long exported genotype fields in export_vcf [hail] Fix unnecessarily long exported genotype fields in export_vcf Feb 12, 2019
@jigold
Copy link
Collaborator

jigold commented Feb 12, 2019

Ok. but I'll make an issue for it.

jigold
jigold previously approved these changes Feb 12, 2019
@jigold jigold dismissed their stale review February 12, 2019 16:56

second thoughts

@jigold
Copy link
Collaborator

jigold commented Feb 12, 2019

I don't think your change preserves the semantics. I think you need this:

    if (end == 0) {
         tg.fields(formatFieldOrder(0)).typ match {
           case TCall => sb += './.'
           case _ => sb += '.'
}  else {

@tpoterba
Copy link
Contributor Author

oh, you're totally right. I actually fixed this in the missing-struct case too.

@tpoterba
Copy link
Contributor Author

good catch!

jigold
jigold previously requested changes Feb 12, 2019
end -= 1

if (end == 0)
sb.append("./.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't you need to change it here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

duh, yes.

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

3 participants