-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aligner: create file/folder structure to the hpg-aligner and add the …
…jni functions. #8
- Loading branch information
Showing
15 changed files
with
224 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
hpg-bigdata-core/native/jni/org_opencb_hpg_bigdata_core_NativeAligner.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "org_opencb_hpg_bigdata_core_NativeAligner.h" | ||
|
||
//------------------------------------------------------------------------------// | ||
|
||
void *load_index(char *index_path); | ||
void free_index(void *index); | ||
|
||
char *map(char *fastq, void *index); | ||
|
||
//------------------------------------------------------------------------------// | ||
|
||
JNIEXPORT jlong JNICALL Java_org_opencb_hpg_bigdata_core_NativeAligner_load_1index | ||
(JNIEnv *env, jobject this, jstring index_path) { | ||
|
||
const char *path = (*env)->GetStringUTFChars(env, index_path, NULL); | ||
void *index = load_index(path); | ||
return ((long) index); | ||
} | ||
|
||
//------------------------------------------------------------------------------// | ||
|
||
JNIEXPORT void JNICALL Java_org_opencb_hpg_bigdata_core_NativeAligner_free_1index | ||
(JNIEnv *env, jobject this, jlong index) { | ||
|
||
free_index((void *) index); | ||
} | ||
|
||
//------------------------------------------------------------------------------// | ||
|
||
JNIEXPORT jstring JNICALL Java_org_opencb_hpg_bigdata_core_NativeAligner_map | ||
(JNIEnv *env, jobject this, jstring fastq, jlong index) { | ||
|
||
const char *reads = (*env)->GetStringUTFChars(env, fastq, NULL); | ||
char *sam = map(reads, (void *)index); | ||
|
||
jstring res = (*env)->NewStringUTF(env, sam); | ||
|
||
// free memory | ||
if (sam) free(sam); | ||
|
||
// return | ||
return res; | ||
} | ||
|
||
//------------------------------------------------------------------------------// | ||
//------------------------------------------------------------------------------// |
37 changes: 37 additions & 0 deletions
37
hpg-bigdata-core/native/jni/org_opencb_hpg_bigdata_core_NativeAligner.h
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 4 additions & 3 deletions
7
...g_opencb_hpg_bigdata_core_NativeSupport.c → ...opencb_hpg_bigdata_core_NativeConverter.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
hpg-bigdata-core/native/jni/org_opencb_hpg_bigdata_core_NativeConverter.h
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
hpg-bigdata-core/native/jni/org_opencb_hpg_bigdata_core_NativeSupport.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
#gcc -O3 -std=gnu99 ./converters/bam2ga.c jni/org_opencb_hpg_bigdata_core_NativeSupport.c -o $olib -shared -fPIC -I third-party/avro-c-1.7.7/src/ -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I $JAVA_HOME/include/darwin -I third-party/ -I third-party/htslib/ -L third-party/avro-c-1.7.7/build/src/ -L third-party/htslib/ -lhts -lavro -lpthread | ||
gcc -O3 -std=gnu99 hpg-aligner.c index.c mapper.c -o hpg-aligner | ||
|
||
olib="libhpgaligner.so" | ||
gcc -O3 -std=gnu99 hpg-aligner.c index.c mapper.c -o $olib -shared -fPIC |
Binary file not shown.
30 changes: 30 additions & 0 deletions
30
hpg-bigdata-core/native/third-party/hpg-aligner/hpg-aligner.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
// | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
void *load_index(char *index_path); | ||
void free_index(void *index); | ||
|
||
char *map(char *fastq, void *index); | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
// main | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
void main() { | ||
// load index | ||
char *index_path = "/toto/index.sa"; | ||
void *index = load_index(index_path); | ||
|
||
// mapping | ||
char *fastq = "@read1\nACTACTACTACTGG\n+\n22222222222222\n@read2\nGAGTTCCAAAGGGG\n+\n22222222222222\n"; | ||
char *sam = map(fastq, index); | ||
|
||
printf("fastq:\n%s\n", fastq); | ||
printf("sam:\n%s\n", sam); | ||
|
||
// free memory | ||
free(sam); | ||
free_index(index); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
// | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
void *load_index(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); | ||
return (void *) index; | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
// | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
void free_index(void *index) { | ||
if (index) { | ||
printf("Freeing index...\n\t%s\n...done!\n", (char *) index); | ||
free((char *) index); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
// | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
char *map(char *fastq, char *index_path) { | ||
char *sam = (char *) calloc(100, sizeof(char)); | ||
sprintf(sam, "read1\t10\t20\t100M\tATAAATTACGGGGGAGA\nread2\t10\t20\t100M\tATAAATTACGGGGGAGA\n"); | ||
//printf("Mapping...\n%s\n%s\n...done!\n", fastq, sam); | ||
return sam; | ||
} |
26 changes: 26 additions & 0 deletions
26
hpg-bigdata-core/src/main/java/org/opencb/hpg/bigdata/core/NativeAligner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2015 OpenCB | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.opencb.hpg.bigdata.core; | ||
|
||
public class NativeAligner { | ||
// index | ||
public native long load_index(String indexPath); | ||
public native void free_index(long index); | ||
|
||
// map | ||
public native String map(String sequences, long index); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters