Skip to content

Commit

Permalink
init code space
Browse files Browse the repository at this point in the history
  • Loading branch information
Griffan authored and griffan committed Jan 14, 2019
1 parent 982d075 commit e3ff00b
Show file tree
Hide file tree
Showing 90 changed files with 24,111 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@
*.exe
*.out
*.app

.idea
cmake-build-debug/
build
htslib
bin
136 changes: 136 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
cmake_minimum_required(VERSION 2.8.4)
project(freemuxlet)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -pthread")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")


include(ExternalProject)
ExternalProject_Add(HTSLIB
PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/build
STAMP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/stamp
GIT_REPOSITORY https://github.com/samtools/htslib.git
GIT_TAG "master"
UPDATE_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/htslib
CONFIGURE_COMMAND autoheader && autoconf && ${CMAKE_CURRENT_SOURCE_DIR}/htslib/configure --prefix=${CMAKE_CURRENT_SOURCE_DIR}/htslib --disable-lzma
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/htslib
BUILD_COMMAND make && make test
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/htslib/include/)

add_executable(freemuxlet
allele.cpp
allele.h
bam_endian.h
bam_ordered_reader.cpp
bam_ordered_reader.h
bcf_chunked_reader.cpp
bcf_chunked_reader.h
bcf_filter_arg.h
bcf_filtered_reader.cpp
bcf_filtered_reader.h
bcf_variant_key.h
bgzf.h
bh_tsne.cpp
bh_tsne.h
cmd_cram_demuxlet.cpp
cmd_cram_digital_pileup.cpp
cmd_cram_freemuxlet.cpp
cmd_cram_gtf_util.cpp
cmd_cram_mux_pileup.cpp
cmd_cram_simuxlet.cpp
cmd_plp_find_mux_clust.cpp
cmd_plp_make_dge_matrix.cpp
cmd_sc_kallisto_count.cpp
cmd_sc_map_stamps.cpp
cmd_sc_multinom_em.cpp
cmd_sc_multinom_gibbs.cpp
commands.cpp
commands.h
config.h
Constant.h
cramore.cpp
cramore.h
discrete_log_helper.h
dropseq.cpp
dropseq.h
Error.cpp
Error.h
filter.cpp
filter.h
genome_interval.cpp
genome_interval.h
genomeChunk.cpp
genomeChunk.h
genomeLoci.h
gtf.cpp
gtf.h
gtf_interval_tree.h
hts_utils.cpp
hts_utils.h
interval.cpp
interval.h
interval_tree.cpp
interval_tree.h
IO.cpp
IO.h
knetfile.h
ksort.h
kstring.h
log_tool.cpp
log_tool.h
louvain.h
params.cpp
params.h
pException.h
PhredHelper.cpp
PhredHelper.h
reference_sequence.cpp
reference_sequence.h
sam_filtered_reader.cpp
sam_filtered_reader.h
sam_ordered_writer.cpp
sam_ordered_writer.h
sc_drop_seq.cpp
sc_drop_seq.h
sptree.cpp
sptree.h
tcf.h
tsv_reader.cpp
tsv_reader.h
utils.cpp
utils.h
variant.cpp
variant.h
variant_manip.cpp
variant_manip.h
vntr.cpp
vntr.h
vptree.h
)
add_dependencies(freemuxlet HTSLIB)

find_library(ZLIB z HINTS /usr/lib/x86_64-linux-gnu/ /usr/lib/ /usr/lib64/)
if(NOT ZLIB)
message(FATAL_ERROR "libz library not found")
endif()

find_library(CURLLIB curl HINTS /usr/lib/x86_64-linux-gnu/ /usr/lib/ /usr/lib64/)
if(NOT CURLLIB)
message(FATAL_ERROR "libcurl library not found")
endif()

find_library(BZ2LIB bz2 HINTS /usr/lib/x86_64-linux-gnu/ /usr/lib/ /usr/lib64/)
if(NOT BZ2LIB)
message(FATAL_ERROR "libbz2 library not found")
endif()

find_library(CRYPTOLIB crypto HINTS /usr/lib/x86_64-linux-gnu/ /usr/lib/ /usr/lib64/)
if(NOT CRYPTOLIB)
message(FATAL_ERROR "libcrypto library not found")
endif()

target_link_libraries(freemuxlet ${CMAKE_CURRENT_SOURCE_DIR}/htslib/libhts.a ${ZLIB} ${BZ2LIB} ${CURLLIB} ${CRYPTOLIB})
60 changes: 60 additions & 0 deletions Constant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2010 Regents of the University of Michigan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _CONSTANT_H_
#define _CONSTANT_H_

#define COMPAREFUNC (int (*)(const void *, const void *))

#define BUFSIZE 1024
#define FILENAMELEN 100
#define IDLEN 20

#define SEPARATORS " \t\n\r\f/"
#define WHITESPACE " \t\n\r\f"

#define SWTABLESKIP 9
#define SWTABLEMAX 10000

#define _NAN_ ((double) (6.66666e-66))

#define QTDTDATA "qtdt.dat"
#define QTDTPED "qtdt.ped"
#define QTDTIBD "qtdt.ibd"
#define QTDTRAW "regress.tbl"
#define GENIHDATAIN "genih.dat"

#ifndef _WIN32
#define stricmp strcasecmp
#endif

// Constants for older haplotype handling programs
// Constants for HAPLOXT
#define XT_MAX_ALLELES 50 // Maximum alleles for crosstabulation
#define XT_VECTORSIZE 10000 // Total haplotypes in population
#define XT_POOLTRESH 7 // Threshold for pooling rare alleles
// Simwalk Haplotype Vectors
#define HV_MAXSIZE 100 // Haplotypes in single SimWalk pedigree
#define HV_INFOTRESH 75 // Percentage of loci typed
#define HV_STATELENGTH 100 // Markers per haplotype
#define HV_SKIPLINES 4 // lines to skip at bottom of family tree
// Simwalk Summary Files
#define HT_TABLE_SIZE 1000
#define HT_SKIP_LINES 9

#endif

126 changes: 126 additions & 0 deletions Error.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright (C) 2010 Regents of the University of Michigan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Error.h"
#include "pException.h"

#include <string>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <stdarg.h>

int32_t globalVerbosityThreshold = 100;

void error(const char * msg, ...)
{
va_list ap;

va_start(ap, msg);

fprintf(stderr, "\nFATAL ERROR - \n");
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n\n");

va_end(ap);

throw pexception;
//exit(EXIT_FAILURE);
}

void warning(const char * msg, ...)
{
va_list ap;

va_start(ap, msg);

time_t current_time;
char buff[255];
current_time = time(NULL);

strftime(buff, 120, "%Y/%m/%d %H:%M:%S", localtime(&current_time));

fprintf(stderr,"\aWARNING [%s] - ", buff);
vfprintf(stderr, msg, ap);
fprintf(stderr,"\n");

va_end(ap);
}

void numerror(const char * msg , ...)
{
va_list ap;

va_start(ap, msg);

fprintf(stderr,"\nFATAL NUMERIC ERROR - ");
vfprintf(stderr, msg, ap);
fprintf(stderr,"\n\n");

va_end(ap);

exit(EXIT_FAILURE);
}

void notice(const char * msg, ...) {
va_list ap;
va_start(ap, msg);

time_t current_time;
char buff[255];
current_time = time(NULL);

strftime(buff, 120, "%Y/%m/%d %H:%M:%S", localtime(&current_time));

fprintf(stderr,"NOTICE [%s] - ", buff);
vfprintf(stderr, msg, ap);
fprintf(stderr,"\n");

va_end(ap);
}

void verbose(int32_t priority, const char * msg, ...) {
va_list ap;
va_start(ap, msg);

if ( globalVerbosityThreshold < priority ) {
time_t current_time;
char buff[255];
current_time = time(NULL);

strftime(buff, 120, "%Y/%m/%d %H:%M:%S", localtime(&current_time));

fprintf(stderr,"VERBOSE_MESSAGE_%d [%s] - ", priority, buff);
vfprintf(stderr, msg, ap);
fprintf(stderr,"\n");
}

va_end(ap);
}

void catprintf(std::string &s, const char * msg, ...)
{
va_list ap;

va_start(ap, msg);

char buf[1000];
vsprintf(buf, msg, ap);

s += buf;
va_end(ap);
}
46 changes: 46 additions & 0 deletions Error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2010 Regents of the University of Michigan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _ERROR_H_
#define _ERROR_H_

#include <string>

extern "C" {
size_t hts_realloc_or_die(unsigned long, unsigned long, unsigned long, unsigned long, int, void**, char const*);
}


// #ifdef __cplusplus
// extern "C" {
// #endif

void error(const char * msg, ...);
void warning(const char * msg, ...);
void numerror(const char * msg, ...);
void notice(const char * msg, ...);
void verbose(int32_t priority, const char * msg, ...);
void catprintf(std::string &s, const char * msg, ...);

extern int32_t globalVerbosityThreshold;

// #ifdef __cplusplus
// };
// #endif


#endif
Loading

0 comments on commit e3ff00b

Please sign in to comment.