summaryrefslogtreecommitdiff
path: root/biology/ucsc-userapps/files/kent.c
blob: f1c8887068f568c609cbce00949135e06c708f3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/***************************************************************************
 *  Description:
 *      Wrapper to turn ucsc kent commands into subcommands.  The kent suite
 *      contains executables that conflict with multiple other software
 *      packages and therefore cannot be safely installed directly under a
 *      standard prefix.  This wrapper can be installed under the standard
 *      PATH and used to to execute kent commands installed under a
 *      private prefix, without altering PATH, activating a special
 *      environment, opening a container, etc.  This sub-command paradigm
 *      is already familiar to bioinformaticians thanks to other suites
 *      like samtools, bedtools, etc.
 *
 *      Example:
 *
 *          kent bigWigToBedGraph args
 *
 *      instead of one of the following:
 *
 *          prefix/bin/bigWigToBedGraph args
 *
 *          env PATH=prefix/bin:$PATH bigWigToBedGraph args
 *
 *          conda activate kent
 *          bigWigToBedGraph args
 *
 *  Arguments:
 *      The full kent utils command you would use if it were in PATH.
 *
 *  Compile with UCSC_PREFIX set to the parent of the bin directory
 *  containing the kent binaries.
 *
 *  History: 
 *  Date        Name        Modification
 *  2021-09-13  Jason Bacon Begin
 ***************************************************************************/

#include <stdio.h>
#include <sysexits.h>
#include <limits.h>
#include <unistd.h>

#ifndef UCSC_PREFIX
#define UCSC_PREFIX   "/usr/local/userapps"
#endif

int     main(int argc,char *argv[])

{
    char    cmd[PATH_MAX + 1];

    if ( argc < 2 )
    {
        fprintf(stderr, "Usage: %s UCSC-userapps-command [args]\n", argv[0]);
        return EX_USAGE;
    }
    
    snprintf(cmd, PATH_MAX, "%s/bin/%s", UCSC_PREFIX, argv[1]);
    execv(cmd, argv + 1);
}