If you happen to see a question you know the answer to, please do chime in and help your fellow community members. We encourage our fourm members to be more involved, jump in and help out your fellow researchers with their questions. GATK forum is a community forum and helping each other with using GATK tools and research is the cornerstone of our success as a genomics research community.We appreciate your help!

Test-drive the GATK tools and Best Practices pipelines on Terra

Check out this blog post to learn how you can get started with GATK and try out the pipelines in preconfigured workspaces (with a user-friendly interface!) without having to install anything.

CommandLine instanceMain method does holds index file open

lordjoelordjoe Member
edited July 2012 in Ask the GATK team

I am writing a Java program to a call a number of CommandLine classes in succession to sort, reorder, index
I call SortSam, CleanSam,AddOrReplaceReadGroups, ReorderSam. Each call has a main which calls System.exit. Instead if calling that main (which would kill my pipeline, I call instanceMain on the relevant class using reflection. I want to pass as output file tmp.bam and expect tmp.bai to be generated as an index. That works.
After I call invokeMain I want to rename the tmp file and the tmp index to the original names. I first rename the original to get it out of the way and also the original index file .
My problem is that the original index file has not been closed and cannot be moved out of the way.
While it is true that calling System.exit (as the CommandLine main does) addresses this issue - this is a VERY BLUNT HAMMER and precludes writing a program which chains command line operations.
How can I close the index file without calling System.exit


  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie admin

    Um, hammers are always blunt, aren't they? Otherwise they're picks ;)

    Kidding aside, I'm afraid we don't normally provide support for programming-level issues. I'll see if someone on the engineering team has time to take your question, but I can't guarantee they'll be able to get back to you quickly. You'll probably have better luck figuring it out on your own, for example by looking at what similar programs by other people do to handle this.

    Good luck!

  • CarneiroCarneiro Charlestown, MAMember admin

    Or maybe ask the community!

Sign In or Register to comment.