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
Collaborator

@tpoterba tpoterba commented Feb 8, 2019

No description provided.

@tpoterba
Copy link
Collaborator Author

@tpoterba 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.

Copy link
Collaborator

@jigold jigold 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))
Copy link
Collaborator

@jigold jigold Feb 11, 2019

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
Collaborator Author

@tpoterba tpoterba Feb 12, 2019

renamed to fieldDefined.

@tpoterba
Copy link
Collaborator Author

@tpoterba tpoterba 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.

@tpoterba tpoterba dismissed jigold’s stale review Feb 12, 2019

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

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

@jigold 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
Collaborator Author

@tpoterba tpoterba commented Feb 12, 2019

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

@tpoterba
Copy link
Collaborator Author

@tpoterba tpoterba commented Feb 12, 2019

good catch!

end -= 1

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

@jigold jigold Feb 12, 2019

Don't you need to change it here too?

Copy link
Collaborator Author

@tpoterba tpoterba Feb 12, 2019

duh, yes.

jigold
jigold approved these changes Feb 12, 2019
@danking danking merged commit d9cdacd into hail-is:master Feb 12, 2019
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants