Skip to content

Commit

Permalink
Merge branch 'release/1.14.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Jones committed Nov 19, 2019
2 parents 6d62e7b + 38f5be4 commit d368367
Show file tree
Hide file tree
Showing 19 changed files with 250 additions and 81 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@ install: true
compiler:
- gcc

before_script:
- wget https://sourceforge.net/projects/linasm/files/linasm-1.13%28stable%29.tar.gz/download -O linasm.tar.gz
- tar -xzf linasm.tar.gz
- pushd linasm-1.13\(stable\) && make && sudo make install prefix=/usr && popd
- export PATH=/usr/bin:$PATH
- export C_INCLUDE_PATH=/usr/include/:$C_INCLUDE_PATH
- export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH

script:
- ./setup.sh ~/wtsi-opt
- ./setup.sh ~/wtsi-opt
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGES

## 1.14.0

* Making species and assembly required commandline arguments in the estep
* Change method by which read position index is resolved. Results in time saving.
* linasm is now required [linasm](http://linasm.sourceforge.net/index.php)
* New log and exp functions from [linasm](http://linasm.sourceforge.net/index.php)

## 1.13.16

* Correct occasional memory blowout caused by split step not excluding an ignore region.
Expand Down
4 changes: 3 additions & 1 deletion INSTALL.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ System Requirements

caveman is designed to run in a compute farm/clustre environment.
caveman depends on:
htslib 1.3 <https://github.com/samtools/htslib/releases/download/1.3/htslib-1.3.tar.bz2>
htslib >=1.3 <https://github.com/samtools/htslib/releases/download/1.3/htslib-1.3.tar.bz2>
zlib >=1.2.3.5 <https://www.zlib.net/>
linasm >=1.13 <http://linasm.sourceforge.net/>


Compilation
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CAVEMAN_VERSION=1.13.16
CAVEMAN_VERSION=1.14.0

TEST_REF?=""
#Compiler
Expand Down Expand Up @@ -33,7 +33,7 @@ LFLAGS?=-L$(HTSTMP)
# define any libraries to link into executable:
# if I want to link in libraries (libx.so or libx.a) I use the -llibname
# option, something like (this will link in libmylib.so and libm.so:
LIBS =-lhts -lpthread -lz -lm -ldl
LIBS =-lhts -lpthread -lz -lm -ldl -llinasm

# define the C source files
SRCS = ./src/file_tests.c ./src/List.c ./src/List_algos.c ./src/bam_access.c ./src/config_file_access.c ./src/fai_access.c ./src/ignore_reg_access.c ./src/alg_bean.c ./src/split_access.c ./src/covs_access.c ./src/cn_access.c ./src/genotype.c ./src/algos.c ./src/output.c ./src/setup.c ./src/split.c ./src/mstep.c ./src/merge.c ./src/estep.c
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ See INSTALL.TXT
* Reference.fasta and index
* A one based bed style format file of regions to ignore during analysis (see specified format).
* [zlib](https://zlib.net/) >= 1.2.3.5
* [linasm](http://linasm.sourceforge.net/index.php) >= 1.13

## Optional inputs (will result in more accurate calls)

Expand Down
2 changes: 2 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ fi

export HTSLIB="$SETUP_DIR/htslib"

set -e

echo -n "Building CaVEMan ..."
if [ -e "$SETUP_DIR/caveman.success" ]; then
echo -n " previously installed ...";
Expand Down
68 changes: 59 additions & 9 deletions src/alg_bean.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <assert.h>
#include <stdlib.h>
#include <libgen.h>
#include <dbg.h>
#include <alg_bean.h>
#include <bam_access.h>
Expand Down Expand Up @@ -166,11 +167,11 @@ int alg_bean_get_index_for_char_arr(List *list,char *val){
return -1;
}

int alg_bean_get_index_for_read_pos_prop_arr(List *list,int pos,int rd_len){
List *lengths = List_create();
int i=0;
int last_stop = 1;
LIST_FOREACH(list, first, next, cur){
List *alg_bean_get_position_list_from_read_pos_proportion_arr(List *list,int rd_len){
List *lengths = List_create();
int last_stop = 1;
int i=0;
LIST_FOREACH(list, first, next, cur){
float pct = *((float *)cur->value);
int lng = (((float)rd_len/(float)100) * pct);
alg_bean_intrange *range = malloc(sizeof(alg_bean_intrange));
Expand All @@ -182,11 +183,60 @@ int alg_bean_get_index_for_read_pos_prop_arr(List *list,int pos,int rd_len){
range->to = (range->from) + lng;
last_stop = range->to;
List_push(lengths,range);
i++;
i++;
}
int result = alg_bean_get_index_for_intrange_arr(lengths,pos);
List_clear_destroy(lengths);
return result;
return lengths;
}

int alg_bean_get_index_for_read_pos_prop_arr(void *_hash, int pos,int rd_len){
List *lengths = NULL;
khiter_t k;
khash_t(readlenpos) *h_rd_len = (khash_t(readlenpos)*) _hash;
k = kh_get(readlenpos, h_rd_len, rd_len);
lengths = kh_value(h_rd_len, k);
return alg_bean_get_index_for_intrange_arr(lengths, pos);
}

int alg_bean_add_read_length_arrs(alg_bean_t *bean, char* list_loc, char* contig){
FILE *output_rp = NULL;
khash_t(readlenpos) *h_rd_len;
char *dircpy = NULL;
//Create map, key is readlength, List of sections is value.
char *read_len_pos_arr_file = malloc(strlen(contig) + strlen(list_loc) + 6);
check_mem(read_len_pos_arr_file);
//Create filename here through name concatenation.
dircpy = strdup(list_loc);
strcpy(read_len_pos_arr_file,dirname(dircpy));
strcat(read_len_pos_arr_file,"/readpos.");
strcat(read_len_pos_arr_file,contig);
output_rp = fopen(read_len_pos_arr_file,"r");
check(output_rp != NULL, "Error opening file %s for write.",read_len_pos_arr_file);
free(read_len_pos_arr_file);

h_rd_len = kh_init(readlenpos);
char line[500];
int rd_len_missing = 0;
khiter_t k;
while ( fgets(line,sizeof(line),output_rp) != NULL ){
//75 1-2;3-38;39-56;57-66;67-76;
int len;
char list_txt [4950];
int chk = sscanf(line,"%d\t%s",&len,list_txt);
List *lenrange = alg_bean_parse_int_range(list_txt);
k = kh_put(readlenpos, h_rd_len, len, &rd_len_missing);
if(rd_len_missing){
kh_value(h_rd_len, k) = lenrange;
}
}
fclose(output_rp);

bean->read_len_pos = h_rd_len;
free(dircpy);
return 0;
error:
if(dircpy) free(dircpy);
if(output_rp) fclose(output_rp);
return -1;
}

List *alg_bean_parse_str_list(char *txt){
Expand Down
9 changes: 8 additions & 1 deletion src/alg_bean.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#include <stdio.h>
#include <List.h>
#include "khash.h"

//New hash to store unique readlengths
KHASH_MAP_INIT_INT(readlenpos, List *)

typedef struct alg_bean_intrange{
int from;
Expand All @@ -58,6 +62,7 @@ typedef struct alg_bean_t{
int call_base_size;
List *strand;
int strand_size;
khash_t(readlenpos) *read_len_pos;
} alg_bean_t;

int alg_bean_create_default_file(FILE *file, char *norm, char *tum);
Expand All @@ -72,7 +77,9 @@ List *alg_bean_hard_copy_char_list(List *new_list, List *old);
int alg_bean_get_index_for_str_arr(List *list,char *value);
int alg_bean_get_index_for_intrange_arr(List *list,int value);
int alg_bean_get_index_for_char_arr(List *list,char *value);
int alg_bean_get_index_for_read_pos_prop_arr(List *list,int pos,int rd_len);
int alg_bean_get_index_for_read_pos_prop_arr(void *_hash, int pos,int rd_len);
int alg_bean_add_read_length_arrs(alg_bean_t *bean, char* list_loc, char* contig);
List *alg_bean_get_position_list_from_read_pos_proportion_arr(List *list,int rd_len);

#define CEIL(a, b) (((a) / (b)) + (((a) % (b)) > 0 ? 1 : 0))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
Expand Down
Loading

0 comments on commit d368367

Please sign in to comment.