Skip to content
Pierre Lindenbaum edited this page Jul 29, 2015 · 3 revisions

##Compiling tabix with nextflow.

See also: https://groups.google.com/d/topic/nextflow/1OmquuxUxb0/discussion

I've tested the following statements with the old tabix hosted on sourceforge: https://sourceforge.net/projects/samtools/files/tabix/

First I need to make a few edits in the tabix Makefile in order to add the path to the tabix basedir. So I've added ${PWD} (the place where I should have compile tabix) to the include path and the ld path. I also set the target lib as .PHONY

(...)
INCLUDES=	-I=${PWD}
SUBDIRS=	.
LIBPATH=	-L=${PWD}
(...)
.PHONY:lib
(...)

Generate the makefile as XML:

../make-4.1/bin/xml-make4.1 -n --xml tabix.xml  tabix

The XML:

<?xml version="1.0" encoding="UTF-8"?>
<make shell="/bin/sh" shellflags="-c" path="/home/lindenb/package/jdk1.8.0_40/bin:/home/lindenb/package/eclipse:/home/lindenb/package/jdk1.8.0_40/bin:/home/lindenb/package/eclipse:/home/lindenb/package/firefox:/home/lindenb/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/lindenb/package/edirect" pwd="/home/lindenb/src/xml-patch-make/tabix">
  <target name="bgzf.c" description="bgzf.c" id="2" precious="0" phony="0">
</target>
  <target name="bgzf.h" description="bgzf.h" id="3" precious="0" phony="0">
</target>
  <target name="knetfile.h" description="knetfile.h" id="4" precious="0" phony="0">
</target>
  <target name="bgzf.o" description="bgzf.o" id="1" precious="0" phony="0">
    <prerequisites>
      <prerequisite name="bgzf.c" ref="2"/>
      <prerequisite name="bgzf.h" ref="3"/>
      <prerequisite name="knetfile.h" ref="4"/>
    </prerequisites>
    <statements>
      <statement>	gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix bgzf.c -o bgzf.o</statement>
    </statements>
  </target>
  <target name="kstring.c" description="kstring.c" id="6" precious="0" phony="0">
</target>
  <target name="kstring.h" description="kstring.h" id="7" precious="0" phony="0">
</target>
  <target name="kstring.o" description="kstring.o" id="5" precious="0" phony="0">
    <prerequisites>
      <prerequisite name="kstring.c" ref="6"/>
      <prerequisite name="kstring.h" ref="7"/>
    </prerequisites>
    <statements>
      <statement>	gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix kstring.c -o kstring.o</statement>
    </statements>
  </target>
  <target name="knetfile.c" description="knetfile.c" id="9" precious="0" phony="0">
</target>
  <target name="knetfile.o" description="knetfile.o" id="8" precious="0" phony="0">
    <prerequisites>
      <prerequisite name="knetfile.c" ref="9"/>
      <prerequisite name="knetfile.h" ref="4"/>
    </prerequisites>
    <statements>
      <statement>	gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix knetfile.c -o knetfile.o</statement>
    </statements>
  </target>
  <target name="index.c" description="index.c" id="11" precious="0" phony="0">
</target>
  <target name="tabix.h" description="tabix.h" id="12" precious="0" phony="0">
</target>
  <target name="khash.h" description="khash.h" id="13" precious="0" phony="0">
</target>
  <target name="ksort.h" description="ksort.h" id="14" precious="0" phony="0">
</target>
  <target name="index.o" description="index.o" id="10" precious="0" phony="0">
    <prerequisites>
      <prerequisite name="index.c" ref="11"/>
      <prerequisite name="bgzf.h" ref="3"/>
      <prerequisite name="tabix.h" ref="12"/>
      <prerequisite name="khash.h" ref="13"/>
      <prerequisite name="ksort.h" ref="14"/>
      <prerequisite name="kstring.h" ref="7"/>
    </prerequisites>
    <statements>
      <statement>	gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix index.c -o index.o</statement>
    </statements>
  </target>
  <target name="bedidx.c" description="bedidx.c" id="16" precious="0" phony="0">
</target>
  <target name="kseq.h" description="kseq.h" id="17" precious="0" phony="0">
</target>
  <target name="bedidx.o" description="bedidx.o" id="15" precious="0" phony="0">
    <prerequisites>
      <prerequisite name="bedidx.c" ref="16"/>
      <prerequisite name="kseq.h" ref="17"/>
      <prerequisite name="khash.h" ref="13"/>
    </prerequisites>
    <statements>
      <statement>	gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix bedidx.c -o bedidx.o</statement>
    </statements>
  </target>
  <target name="libtabix.a" description="libtabix.a" id="18" precious="0" phony="0">
    <prerequisites>
      <prerequisite name="bgzf.o" ref="1"/>
      <prerequisite name="kstring.o" ref="5"/>
      <prerequisite name="knetfile.o" ref="8"/>
      <prerequisite name="index.o" ref="10"/>
      <prerequisite name="bedidx.o" ref="15"/>
    </prerequisites>
    <statements>
      <statement>	ar -cru libtabix.a bgzf.o kstring.o knetfile.o index.o bedidx.o</statement>
    </statements>
  </target>
  <target name="lib" description="lib" id="19" precious="0" phony="1">
    <prerequisites>
      <prerequisite name="libtabix.a" ref="18"/>
    </prerequisites>
  </target>
  <target name="main.c" description="main.c" id="21" precious="0" phony="0">
</target>
  <target name="main.o" description="main.o" id="20" precious="0" phony="0">
    <prerequisites>
      <prerequisite name="main.c" ref="21"/>
      <prerequisite name="tabix.h" ref="12"/>
      <prerequisite name="kstring.h" ref="7"/>
      <prerequisite name="bgzf.h" ref="3"/>
    </prerequisites>
    <statements>
      <statement>	gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix main.c -o main.o</statement>
    </statements>
  </target>
  <target name="tabix" description="tabix" id="22" precious="0" phony="0">
    <prerequisites>
      <prerequisite name="lib" ref="19"/>
      <prerequisite name="main.o" ref="20"/>
    </prerequisites>
    <statements>
      <statement>	gcc -g -Wall -O2 -fPIC  -o tabix main.o -lm -L=/home/lindenb/src/xml-patch-make/tabix  -L. -ltabix -lz</statement>
    </statements>
  </target>
</make>

Next, we use the XSLT stylesheet graph2nextflow.xsl to convert this file to tabix.nf

 xsltproc ../stylesheets/graph2nextflow.xsl tabix.xml > tabix.nf

Here is the tabix.nf :

#!/usr/bin/env nextflow



/** bgzf.c */
process proc2	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'bgzf.c' }	
	

	output:
	file 'bgzf.c'
	file 'bgzf.c' into proc_2_to_1
	input:
	file 'bgzf.c' from file('bgzf.c')

	
	'''
	#!/bin/sh
	touch -c 'bgzf.c'
	'''
	}






/** bgzf.h */
process proc3	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'bgzf.h' }	
	

	output:
	file 'bgzf.h'
	file 'bgzf.h' into proc_3_to_1
	file 'bgzf.h' into proc_3_to_10
	file 'bgzf.h' into proc_3_to_20
	input:
	file 'bgzf.h' from file('bgzf.h')

	
	'''
	#!/bin/sh
	touch -c 'bgzf.h'
	'''
	}






/** knetfile.h */
process proc4	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'knetfile.h' }	
	

	output:
	file 'knetfile.h'
	file 'knetfile.h' into proc_4_to_1
	file 'knetfile.h' into proc_4_to_8
	input:
	file 'knetfile.h' from file('knetfile.h')

	
	'''
	#!/bin/sh
	touch -c 'knetfile.h'
	'''
	}






/** bgzf.o */
process proc1	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'bgzf.o' }	
	

	output:
	file 'bgzf.o'
	file 'bgzf.o' into proc_1_to_18
	input:
	file 'bgzf.c' from proc_2_to_1
	file 'bgzf.h' from proc_3_to_1
	file 'knetfile.h' from proc_4_to_1
	
	'''
	#!/bin/sh
		gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix bgzf.c -o bgzf.o
	'''
	}






/** kstring.c */
process proc6	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'kstring.c' }	
	

	output:
	file 'kstring.c'
	file 'kstring.c' into proc_6_to_5
	input:
	file 'kstring.c' from file('kstring.c')

	
	'''
	#!/bin/sh
	touch -c 'kstring.c'
	'''
	}






/** kstring.h */
process proc7	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'kstring.h' }	
	

	output:
	file 'kstring.h'
	file 'kstring.h' into proc_7_to_5
	file 'kstring.h' into proc_7_to_10
	file 'kstring.h' into proc_7_to_20
	input:
	file 'kstring.h' from file('kstring.h')

	
	'''
	#!/bin/sh
	touch -c 'kstring.h'
	'''
	}






/** kstring.o */
process proc5	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'kstring.o' }	
	

	output:
	file 'kstring.o'
	file 'kstring.o' into proc_5_to_18
	input:
	file 'kstring.c' from proc_6_to_5
	file 'kstring.h' from proc_7_to_5
	
	'''
	#!/bin/sh
		gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix kstring.c -o kstring.o
	'''
	}






/** knetfile.c */
process proc9	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'knetfile.c' }	
	

	output:
	file 'knetfile.c'
	file 'knetfile.c' into proc_9_to_8
	input:
	file 'knetfile.c' from file('knetfile.c')

	
	'''
	#!/bin/sh
	touch -c 'knetfile.c'
	'''
	}






/** knetfile.o */
process proc8	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'knetfile.o' }	
	

	output:
	file 'knetfile.o'
	file 'knetfile.o' into proc_8_to_18
	input:
	file 'knetfile.c' from proc_9_to_8
	file 'knetfile.h' from proc_4_to_8
	
	'''
	#!/bin/sh
		gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix knetfile.c -o knetfile.o
	'''
	}






/** index.c */
process proc11	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'index.c' }	
	

	output:
	file 'index.c'
	file 'index.c' into proc_11_to_10
	input:
	file 'index.c' from file('index.c')

	
	'''
	#!/bin/sh
	touch -c 'index.c'
	'''
	}






/** tabix.h */
process proc12	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'tabix.h' }	
	

	output:
	file 'tabix.h'
	file 'tabix.h' into proc_12_to_10
	file 'tabix.h' into proc_12_to_20
	input:
	file 'tabix.h' from file('tabix.h')

	
	'''
	#!/bin/sh
	touch -c 'tabix.h'
	'''
	}






/** khash.h */
process proc13	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'khash.h' }	
	

	output:
	file 'khash.h'
	file 'khash.h' into proc_13_to_10
	file 'khash.h' into proc_13_to_15
	input:
	file 'khash.h' from file('khash.h')

	
	'''
	#!/bin/sh
	touch -c 'khash.h'
	'''
	}






/** ksort.h */
process proc14	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'ksort.h' }	
	

	output:
	file 'ksort.h'
	file 'ksort.h' into proc_14_to_10
	input:
	file 'ksort.h' from file('ksort.h')

	
	'''
	#!/bin/sh
	touch -c 'ksort.h'
	'''
	}






/** index.o */
process proc10	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'index.o' }	
	

	output:
	file 'index.o'
	file 'index.o' into proc_10_to_18
	input:
	file 'index.c' from proc_11_to_10
	file 'bgzf.h' from proc_3_to_10
	file 'tabix.h' from proc_12_to_10
	file 'khash.h' from proc_13_to_10
	file 'ksort.h' from proc_14_to_10
	file 'kstring.h' from proc_7_to_10
	
	'''
	#!/bin/sh
		gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix index.c -o index.o
	'''
	}






/** bedidx.c */
process proc16	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'bedidx.c' }	
	

	output:
	file 'bedidx.c'
	file 'bedidx.c' into proc_16_to_15
	input:
	file 'bedidx.c' from file('bedidx.c')

	
	'''
	#!/bin/sh
	touch -c 'bedidx.c'
	'''
	}






/** kseq.h */
process proc17	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'kseq.h' }	
	

	output:
	file 'kseq.h'
	file 'kseq.h' into proc_17_to_15
	input:
	file 'kseq.h' from file('kseq.h')

	
	'''
	#!/bin/sh
	touch -c 'kseq.h'
	'''
	}






/** bedidx.o */
process proc15	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'bedidx.o' }	
	

	output:
	file 'bedidx.o'
	file 'bedidx.o' into proc_15_to_18
	input:
	file 'bedidx.c' from proc_16_to_15
	file 'kseq.h' from proc_17_to_15
	file 'khash.h' from proc_13_to_15
	
	'''
	#!/bin/sh
		gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix bedidx.c -o bedidx.o
	'''
	}






/** libtabix.a */
process proc18	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'libtabix.a' }	
	

	output:
	file 'libtabix.a'
	file 'libtabix.a' into proc_18_to_19
	input:
	file 'bgzf.o' from proc_1_to_18
	file 'kstring.o' from proc_5_to_18
	file 'knetfile.o' from proc_8_to_18
	file 'index.o' from proc_10_to_18
	file 'bedidx.o' from proc_15_to_18
	
	'''
	#!/bin/sh
		ar -cru libtabix.a bgzf.o kstring.o knetfile.o index.o bedidx.o
	'''
	}






/** lib */
process proc19	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'lib' }	
	

	output:
	file '__19_phony.flag'
	file '__19_phony.flag' into proc_19_to_22
	input:
	file 'libtabix.a' from proc_18_to_19
	
	'''
	#!/bin/sh
	touch '__19_phony.flag'
	'''
	}






/** main.c */
process proc21	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'main.c' }	
	

	output:
	file 'main.c'
	file 'main.c' into proc_21_to_20
	input:
	file 'main.c' from file('main.c')

	
	'''
	#!/bin/sh
	touch -c 'main.c'
	'''
	}






/** main.o */
process proc20	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'main.o' }	
	

	output:
	file 'main.o'
	file 'main.o' into proc_20_to_22
	input:
	file 'main.c' from proc_21_to_20
	file 'tabix.h' from proc_12_to_20
	file 'kstring.h' from proc_7_to_20
	file 'bgzf.h' from proc_3_to_20
	
	'''
	#!/bin/sh
		gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I=/home/lindenb/src/xml-patch-make/tabix main.c -o main.o
	'''
	}






/** tabix */
process proc22	{

	/* http://www.nextflow.io/docs/latest/process.html#storedir */
	storeDir  '/home/lindenb/src/xml-patch-make/tabix'
	
	tag { 'tabix' }	
	

	output:
	file 'tabix'
	input:
	file '__19_phony.flag' from proc_19_to_22
	file 'main.o' from proc_20_to_22
	
	'''
	#!/bin/sh
		gcc -g -Wall -O2 -fPIC  -o tabix main.o -lm -L=/home/lindenb/src/xml-patch-make/tabix  -L. -ltabix -lz
	'''
	}

run nextflow:

$ nextflow run jeter.nf 
N E X T F L O W  ~  version 0.15.0
Launching jeter.nf
[warm up] executor > local
[skipping] Stored process > proc2 (bgzf.c)
[skipping] Stored process > proc3 (bgzf.h)
[skipping] Stored process > proc4 (knetfile.h)
[skipping] Stored process > proc6 (kstring.c)
[skipping] Stored process > proc7 (kstring.h)
[skipping] Stored process > proc9 (knetfile.c)
[skipping] Stored process > proc11 (index.c)
[skipping] Stored process > proc12 (tabix.h)
[28/76ed7d] Submitted process > proc1 (bgzf.o)
[d4/0d42db] Submitted process > proc8 (knetfile.o)
[skipping] Stored process > proc13 (khash.h)
[skipping] Stored process > proc14 (ksort.h)
[skipping] Stored process > proc16 (bedidx.c)
[skipping] Stored process > proc17 (kseq.h)
[skipping] Stored process > proc21 (main.c)
[56/944914] Submitted process > proc5 (kstring.o)
[be/3ef396] Submitted process > proc10 (index.o)
[11/9a69cd] Submitted process > proc15 (bedidx.o)
[28/b4a0b5] Submitted process > proc20 (main.o)
[97/ebc79f] Submitted process > proc18 (libtabix.a)
[skipping] Stored process > proc19 (lib)
[f1/70b0cc] Submitted process > proc22 (tabix)


$ find ./work -name "*.o" -o -name "tabix"
./work/d4/0d42dbe6525b56d3fda2971cafb125/knetfile.o
./work/97/ebc79f8b03a782880773c8061b05c8/kstring.o
./work/97/ebc79f8b03a782880773c8061b05c8/bgzf.o
./work/97/ebc79f8b03a782880773c8061b05c8/knetfile.o
./work/97/ebc79f8b03a782880773c8061b05c8/index.o
./work/97/ebc79f8b03a782880773c8061b05c8/bedidx.o
./work/56/944914decd5ef8ea5ed4f084e3768c/kstring.o
./work/f1/70b0cc519596d836e12d33c3afbabd/tabix
./work/f1/70b0cc519596d836e12d33c3afbabd/main.o
./work/28/b4a0b5166c1b827d5ec2c7891adbd2/main.o
./work/28/76ed7d80f7042c767edda9f54e8a2f/bgzf.o
./work/11/9a69cdb7aec0ecf490adbe20390cfb/bedidx.o
./work/be/3ef396aee0e05b55557e6203f54296/index.o

$ ./work/f1/70b0cc519596d836e12d33c3afbabd/tabix -h

Program: tabix (TAB-delimited file InderXer)
Version: 0.2.5 (r964)

Usage:   tabix <in.tab.bgz> [region1 [region2 [...]]]

Options: -p STR     preset: gff, bed, sam, vcf, psltbl [gff]
         -s INT     sequence name column [1]
         -b INT     start column [4]
         -e INT     end column; can be identical to '-b' [5]
         -S INT     skip first INT lines [0]
         -c CHAR    symbol for comment/meta lines [#]
         -r FILE    replace the header with the content of FILE [null]
         -B         region1 is a BED file (entire file will be read)
         -0         zero-based coordinate
         -h         print the header lines
         -l         list chromosome names
         -f         force to overwrite the index
Clone this wiki locally