Skip to content

Commit

Permalink
Merge pull request #11 from broadinstitute/vrr_update_bwa_commit
Browse files Browse the repository at this point in the history
Update to the new Apache2 branch head commit (cb950614ce72).
  • Loading branch information
Valentin Ruano Rubio authored Aug 14, 2017
2 parents 7c053c9 + fafdbd2 commit bf22f4a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 115 deletions.
8 changes: 3 additions & 5 deletions src/main/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ else
LIB_EXT=Linux.so
endif

BWA_MEM_COMMIT=ec85a563e64710e7fc8c8c0b373d80570e245bd1
BWA_MEM_COMMIT=cb950614ce7217788780b9a8d445c64cd4d8f62e
JNI_BASE_NAME=org_broadinstitute_hellbender_utils_bwa_BwaMemIndex

all: libbwa.$(LIB_EXT)

libbwa.$(LIB_EXT): $(JNI_BASE_NAME).o jnibwa.o bwtidxbuild.o bwa/libbwa.a
libbwa.$(LIB_EXT): $(JNI_BASE_NAME).o jnibwa.o bwa/libbwa.a
$(CC) -ggdb -dynamiclib -shared -o $@ $^ -lm -lz -lpthread

bwa:
git clone https://github.com/lh3/bwa && cd bwa && git checkout $(BWA_MEM_COMMIT) && echo '#define BWA_COMMIT "'$(BWA_MEM_COMMIT)'"' > bwa_commit.h
sed -i .bak 's/\(LOBJS=.*\)/\1 $$(AOBJS)/g' bwa/Makefile
sed -i.bak -e's/\(LOBJS=.*\)/\1 bwtindex.o rle.o rope.o bwt.o is.o/g' bwa/Makefile

bwa/libbwa.a: bwa
$(MAKE) CFLAGS="$(CFLAGS)" -C bwa libbwa.a
Expand All @@ -33,8 +33,6 @@ $(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c jnibwa.h bwa

jnibwa.o: jnibwa.c jnibwa.h bwa

bwtidxbuild.o: bwtidxbuild.c bwa

clean:
rm -rf bwa *.o *.$(LIB_EXT)

Expand Down
104 changes: 0 additions & 104 deletions src/main/c/bwtidxbuild.c

This file was deleted.

26 changes: 20 additions & 6 deletions src/main/c/org_broadinstitute_hellbender_utils_bwa_BwaMemIndex.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,31 @@ char * jstring_to_chars(JNIEnv* env, jstring in) {
return res;
}

jint throwIllegalArgumentException(JNIEnv* env, char* message) {
jclass iaeClass = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
return (*env)->ThrowNew(env, iaeClass, message);
}

JNIEXPORT jboolean JNICALL
Java_org_broadinstitute_hellbender_utils_bwa_BwaMemIndex_createReferenceIndex( JNIEnv* env, jclass cls, jstring jReferenceFileName, jstring jIndexPrefix, jstring jAlgoName) {

extern int bwt_idx_build(const char*, const char*, const char*);
char *reference_file_name = jstring_to_chars(env, jReferenceFileName);
char *index_prefix = jstring_to_chars(env, jIndexPrefix);
char *algo_name = jstring_to_chars(env, jAlgoName);
int algo_type;
if (strcmp(algo_name, "auto") == 0) algo_type = 0;
else if (strcmp(algo_name, "is") == 0) algo_type = 3;
else if (strcmp(algo_name, "rb2") == 0) algo_type = 1;
else {
char* message = malloc(sizeof(char) * (strlen(algo_name) + 100));
sprintf(message, "wrong algorithm name '%s'", algo_name);
throwIllegalArgumentException(env, message);
free(message);
return 0;
}
jboolean res = !bwa_idx_build( reference_file_name, index_prefix, algo_type, -1);
free(reference_file_name); free(index_prefix); free(algo_name);

char *referenceFileName = jstring_to_chars(env, jReferenceFileName);
char *indexPrefix = jstring_to_chars(env, jIndexPrefix);
char *algoName = jstring_to_chars(env, jAlgoName);
jboolean res = !bwt_idx_build( referenceFileName, indexPrefix, algoName);
free(referenceFileName); free(indexPrefix); free(algoName);
return res;
}

Expand Down

0 comments on commit bf22f4a

Please sign in to comment.