Skip to content

Commit

Permalink
align: build the dynamic library for hpg-aligner (not finished yet). #8
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Jun 1, 2015
1 parent 9e38f84 commit ab1d8ea
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 23 deletions.
59 changes: 58 additions & 1 deletion hpg-bigdata-core/native/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,61 @@ fi
echo
echo "Building the dynamic library $olib"

gcc -O3 -std=gnu99 jni/org_opencb_hpg_bigdata_core_NativeAligner.c ./third-party/hpg-aligner/index.c ./third-party/hpg-aligner/mapper.c -o $olib -shared -fPIC -I jni/ -I third-party/hpg-aligner -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I $JAVA_HOME/include/darwin
#gcc -O3 -std=gnu99 jni/org_opencb_hpg_bigdata_core_NativeAligner.c ./third-party/hpg-aligner/index.c ./third-party/hpg-aligner/mapper.c -o $olib -shared -fPIC -I jni/ -I third-party/hpg-aligner -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I $JAVA_HOME/include/darwin


#gcc -O3 -std=gnu99 src/*.c src/rna/*.c src/dna/*.c src/build-index/*.c src/tools/bam/aux/*.c src/tools/bam/recalibrate/*.c src/tools/bam/aligner/*.c -o final.so -shared -fPIC -I src -I src/rna -I src/dna -I src/build-index/ -I src/tools/bam/ -I src/tools/bam/recalibrate/ -I src/tools/bam/aligner/ -I lib/hpg-libs/third_party/ -I lib/hpg-libs/third_party/htslib/ -I lib/hpg-libs/c/src/ -I jni/ -I third-party/hpg-aligner -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I $JAVA_HOME/include/darwin

hpg_alinger_home="../../../hpg-aligner"
hpg_libs_home="../../../hpg-aligner/lib/hpg-libs/c/src"
cprops_home="../../../hpg-aligner/lib/hpg-libs/third_party"
gcc -O3 -std=gnu99 jni/org_opencb_hpg_bigdata_core_NativeAligner.c ./third-party/hpg-aligner/index.c \
$cprops_home/cprops/avl.c \
$cprops_home/cprops/collection.c \
$cprops_home/cprops/hashlist.c \
$cprops_home/cprops/hashtable.c \
$cprops_home/cprops/heap.c \
$cprops_home/cprops/linked_list.c \
$cprops_home/cprops/log.c \
$cprops_home/cprops/mempool.c \
$cprops_home/cprops/rb.c \
$cprops_home/cprops/util.c \
$cprops_home/cprops/vector.c \
$cprops_home/cprops/trie.c \
$cprops_home/cprops/mtab.c \
$hpg_libs_home/commons/*.c \
$hpg_libs_home/containers/*.c \
$hpg_libs_home/bioformats/fastq/*.c \
$hpg_libs_home/bioformats/bam/*.c \
$hpg_libs_home/aligners/bwt/bwt_commons.c \
$hpg_libs_home/aligners/bwt/genome.c \
$hpg_libs_home/aligners/bwt/bwt.c \
$hpg_libs_home/aligners/sw/macros.c \
$hpg_libs_home/aligners/sw/sse.c \
$hpg_libs_home/aligners/sw/smith_waterman.c \
$hpg_alinger_home/src/*.c \
$hpg_alinger_home/src/rna/*.c \
$hpg_alinger_home/src/dna/*.c \
$hpg_alinger_home/src/dna/clasp_v1_1/*.c \
$hpg_alinger_home/src/sa/*.c \
$hpg_alinger_home/src/build-index/*.c \
$hpg_alinger_home/src/tools/bam/aux/*.c \
$hpg_alinger_home/src/tools/bam/recalibrate/*.c \
$hpg_alinger_home/src/tools/bam/aligner/*.c \
-o $olib -shared -fPIC \
-I $hpg_alinger_home/src \
-I $hpg_alinger_home/src/rna \
-I $hpg_alinger_home/src/dna \
-I $hpg_alinger_home/src/build-index/ \
-I $hpg_alinger_home/src/tools/bam/ \
-I $hpg_alinger_home/src/tools/bam/recalibrate/ \
-I $hpg_alinger_home/src/tools/bam/aligner/ \
-I $hpg_alinger_home/lib/hpg-libs/third_party/ \
-I $hpg_alinger_home/lib/hpg-libs/third_party/htslib/ \
-I $hpg_alinger_home/lib/hpg-libs/c/src/ \
-I jni/ \
-I third-party/hpg-aligner \
-I /usr/include/libxml2 \
-I $JAVA_HOME/include \
-I $JAVA_HOME/include/linux \
-I $JAVA_HOME/include/darwin
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ JNIEXPORT jlong JNICALL Java_org_opencb_hpg_bigdata_core_NativeAligner_load_1par
printf("Error getting seqFileName1 parameter\n");
}

// get the field ID of the "seqFileName1" field of this class
fid_string = (*env)->GetFieldID(env, cls, "seqFileName1", "Ljava/lang/String;");
// get the field ID of the "seqFileName2" field of this class
fid_string = (*env)->GetFieldID(env, cls, "seqFileName2", "Ljava/lang/String;");
if (fid_string) {
val_string = (jstring) (*env)->GetObjectField(env, params_obj, fid_string);
if (val_string) {
str = (*env)->GetStringUTFChars(env, val_string, NULL);
params->seq_filename1 = strdup(str);
params->seq_filename2 = strdup(str);
(*env)->ReleaseStringUTFChars(env, val_string, str);
} else {
printf("Error getting String object (seqFileName1)\n");
printf("Error getting String object (seqFileName2)\n");
}
} else {
printf("Error getting seqFileName1 parameter\n");
printf("Error getting seqFileName2 parameter\n");
}

// get the field ID of the "resultFileName" field of this class
Expand Down
20 changes: 15 additions & 5 deletions hpg-bigdata-core/native/third-party/hpg-aligner/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
#include <stdlib.h>
#include <string.h>

#include "aligners/bwt/bwt.h"

//----------------------------------------------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------------------------------------------

void *load_index(const char *index_path) {
char *index = (char *) calloc(100, sizeof(char));
sprintf(index, "index located at %s", index_path);
printf("Loading index...\n\t%s\n...done!\n", index);

printf("Loading index...\n");
bwt_index_t *index = bwt_index_new(index_path, false);
printf("...done! (%x)\n", index);

//char *index = (char *) calloc(100, sizeof(char));
//sprintf(index, "index located at %s", index_path);
//printf("Loading index...\n\t%s\n...done!\n", index);
return (void *) index;
}

Expand All @@ -19,8 +26,11 @@ void *load_index(const char *index_path) {

void free_index(void *index) {
if (index) {
printf("Freeing index...\n\t%s\n...done!\n", (char *) index);
free((char *) index);
printf("Freeing index (%x)...\n", (bwt_index_t *) index);
bwt_index_free((bwt_index_t *) index);
printf("...done!\n");

//free((char *) index);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ public void map(AvroKey<ReadAlignment> key, NullWritable value, Context context)

public static int run(AlignerParams params) throws Exception {
Configuration conf = new Configuration();
conf.set("seqFileName1", params.seqFileName1);
conf.set("seqFileName2", params.seqFileName2);
conf.set("indexFolderName", params.indexFolderName);
conf.set("numSeeds", "" + params.numSeeds);
conf.set("minSWScore", "" + params.minSWScore);
AlignerUtils.updateConfiguration(params, conf);

Job job = Job.getInstance(conf, "ReadAlignMR");
job.setJarByClass(ReadAlignmentAlignMR.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ public void map(AvroKey<Read> key, NullWritable value, Context context) throws I

public static int run(AlignerParams params) throws Exception {
Configuration conf = new Configuration();
conf.set("seqFileName1", params.seqFileName1);
conf.set("seqFileName2", params.seqFileName2);
conf.set("indexFolderName", params.indexFolderName);
conf.set("numSeeds", "" + params.numSeeds);
conf.set("minSWScore", "" + params.minSWScore);
AlignerUtils.updateConfiguration(params, conf);

Job job = Job.getInstance(conf, "ReadAlignMR");
job.setJarByClass(ReadAlignMR.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ public static AlignerParams newAlignerParams(Configuration conf) {
return params;
}

public static void updateConfiguration(AlignerParams params, Configuration conf) {
conf.set("seqFileName1", params.seqFileName1);
conf.set("seqFileName2", params.seqFileName2);
conf.set("indexFolderName", params.indexFolderName);
conf.set("numSeeds", "" + params.numSeeds);
conf.set("minSWScore", "" + params.minSWScore);
}

public void mapReads(String fastq, NativeAligner nativeAligner,
long nativeIndex, long nativeParams,
Mapper.Context context) throws IOException, InterruptedException {
long nativeIndex, long nativeParams,
Mapper.Context context) throws IOException, InterruptedException {

String sam = nativeAligner.map(fastq, nativeIndex, nativeParams);
System.out.println("mapReads, sam:\n" + sam);
Expand Down

0 comments on commit ab1d8ea

Please sign in to comment.