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

Reheader external #1007

Merged
merged 2 commits into from Mar 7, 2019
Merged

Reheader external #1007

merged 2 commits into from Mar 7, 2019

Conversation

valeriuo
Copy link
Contributor

@valeriuo valeriuo commented Feb 8, 2019

Allow an external application to modify the header of the target file and pass back the result to samtools. The external app will read the original header through stdin and output the modified header on stdout.

Fixes #999.

usage(stderr, 1);

{ // read the header
if (external) {
in = sam_open(argv[optind], inplace?"r+":"r");
Copy link
Member

Choose a reason for hiding this comment

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

If you open the file with hopen() followed by hts_hopen(), you will already have the hFILE* and won't have a desire for an hts_hfile() function.

@jmarshall
Copy link
Member

  1. The conventional option letter for stuff like this is -c / --command. cf bash, su.

  2. If you organised this via a function like

bam_hdr_t *rewrite_header(bam_hdr_t *input_header) {
    if (g_external_command_mode) return do_popen(g_command, input_header);
    else return do_sam_hdr_read(g_header_filename);
}

that was called from inside each of the bam/cram_reheader functions, you wouldn't have any need to rewind the input.

  1. It looks like the external program is always given the header in SAM format. IMHO that's the right thing to do, but it should be documented.

@valeriuo
Copy link
Contributor Author

valeriuo commented Feb 8, 2019

Thanks for the review and suggestions.

valeriuo and others added 2 commits March 7, 2019 15:26
Warn that the command in the `-c` option is passed to a shell,
and that it must return a zero exit code.
@daviesrob daviesrob merged commit 33268a9 into samtools:develop Mar 7, 2019
@valeriuo valeriuo deleted the reheader-external branch August 12, 2019 09:47
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