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

Projects
None yet
3 participants
@tpoterba
Copy link
Collaborator

commented Feb 8, 2019

No description provided.

@tpoterba

This comment has been minimized.

Copy link
Collaborator Author

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
Copy link
Collaborator

left a comment

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))

This comment has been minimized.

Copy link
@jigold

jigold Feb 11, 2019

Collaborator

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.

This comment has been minimized.

Copy link
@tpoterba

tpoterba Feb 12, 2019

Author Collaborator

renamed to fieldDefined.

@tpoterba

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 12, 2019

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.

addressed

@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

This comment has been minimized.

Copy link
Collaborator

commented Feb 12, 2019

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

@jigold jigold dismissed their stale review Feb 12, 2019

second thoughts

@jigold

This comment has been minimized.

Copy link
Collaborator

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

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 12, 2019

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

Fix
@tpoterba

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 12, 2019

good catch!

end -= 1

if (end == 0)
sb.append("./.")

This comment has been minimized.

Copy link
@jigold

jigold Feb 12, 2019

Collaborator

Don't you need to change it here too?

This comment has been minimized.

Copy link
@tpoterba

tpoterba Feb 12, 2019

Author Collaborator

duh, yes.

fis
@jigold

jigold approved these changes Feb 12, 2019

@danking danking merged commit d9cdacd into hail-is:master Feb 12, 2019

1 check passed

hail-ci-0-1 successful build
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.