Skip to content

fix(nanno): preserve user-requested field order in AnnotationSourceTSV#402

Draft
Copilot wants to merge 3 commits intonanno_multi_genefrom
copilot/sub-pr-400-again
Draft

fix(nanno): preserve user-requested field order in AnnotationSourceTSV#402
Copilot wants to merge 3 commits intonanno_multi_genefrom
copilot/sub-pr-400-again

Conversation

Copy link

Copilot AI commented Feb 27, 2026

AnnotationSourceTSV.getHeaderNameAndPositions returned a HashMap, causing keySet() iteration in the constructor to produce non-deterministic ordering for fieldNames/fieldPositions arrays — potentially mismatching the user-requested CSV field order and emptyRecordResult.

Changes

  • AnnotationSourceTSV.java: Replace HashMap with LinkedHashMap in getHeaderNameAndPositions so insertion order (driven by fieldNames.split(",")) is preserved when populating the precomputed arrays
  • AnnotateTest.java: Updated expected value in jsonInputsTSV test to match the now-deterministic user-requested field order (aaref,HGVSc_VEP,HGVSp_VEP)
  • Executor.java: Fixed two pre-existing bugs that caused endToEnd and endToEndSnpEff tests to fail:
    • Replaced the literal "java" string with getJavaPath() (derived from java.home) so the correct JVM binary is used regardless of PATH
    • Removed shell-style quotes around the classpath argument — ProcessBuilder does not use a shell, so the literal " characters were being passed to the JVM, preventing class loading
    • Switched Executor(String[], String) and Executor(String jvmArgs, String arguments, String qualifiedMainClassName) constructors to use ProcessBuilder directly with an unquoted classpath

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Existing and updated unit tests in AnnotationSourceTSVTest and AnnotateTest cover the changes.

  • AnnotationSourceTSVTest.extractFieldsFromRecord
  • AnnotationSourceTSVTest.getHeaderNameAndPositions
  • AnnotateTest.jsonInputsTSV
  • AnnotateTest.endToEnd
  • AnnotateTest.endToEndSnpEff

Are WDL Updates Required?

No.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…requested field order

Co-authored-by: holmeso <7066552+holmeso@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on reporting variants in multiple genes fix(nanno): preserve user-requested field order in AnnotationSourceTSV Feb 27, 2026
@holmeso
Copy link
Contributor

holmeso commented Feb 27, 2026

@copilot this causes a failure in a qannotate test

…test expectations

- Revert --enable-preview from build.gradle (List.getFirst/getLast are standard Java 21, not preview)
- Revert --enable-preview from AnnotateTest.java Executor call
- Update jsonInputsTSV expected value to match user-requested field order (aaref,HGVSc_VEP,HGVSp_VEP) with LinkedHashMap
- Fix Executor.java: use getJavaPath() instead of literal "java", remove shell-style quotes from classpath (ProcessBuilder does not use a shell), switch array/jvmArgs constructors to ProcessBuilder

Co-authored-by: holmeso <7066552+holmeso@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 27, 2026

@copilot this causes a failure in a qannotate test

Fixed in commit d646599. There were two separate issues:

  1. AnnotateTest.jsonInputsTSV – the expected value was written for the old HashMap (non-deterministic) ordering. Updated to "aaref=M\tHGVSc_VEP=c.1A>C\tHGVSp_VEP=p.Met1?" which matches the user-requested field order "aaref,HGVSc_VEP,HGVSp_VEP" preserved by the LinkedHashMap.

  2. AnnotateTest.endToEnd / endToEndSnpEff – pre-existing bugs in Executor.java: the 2-arg constructor passed a shell-quoted classpath ("\"...\") to ProcessBuilder, which doesn't use a shell, so the literal quote characters prevented the JVM from loading classes. Also, the "java" literal was replaced with getJavaPath() (derived from java.home) for robustness. List.getFirst()/getLast() are standard Java 21 features — no --enable-preview is needed.

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.

2 participants