Imported Upstream version 2.0.14+dfsg

parent b04eb82d
This diff is collapsed.
This diff is collapsed.
#! /bin/sh
# Wrapper for Microsoft lib.exe
me=ar-lib
scriptversion=2012-03-01.08; # UTC
# Copyright (C) 2010-2012 Free Software Foundation, Inc.
# Written by Peter Rosin <peda@lysator.liu.se>.
#
# 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 2, 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/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# func_error message
func_error ()
{
echo "$me: $1" 1>&2
exit 1
}
file_conv=
# func_file_conv build_file
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv in
mingw)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin)
file=`cygpath -m "$file" || echo "$file"`
;;
wine)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_at_file at_file operation archive
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
# for each of them.
# When interpreting the content of the @FILE, do NOT use func_file_conv,
# since the user would need to supply preconverted file names to
# binutils ar, at least for MinGW.
func_at_file ()
{
operation=$2
archive=$3
at_file_contents=`cat "$1"`
eval set x "$at_file_contents"
shift
for member
do
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
done
}
case $1 in
'')
func_error "no command. Try '$0 --help' for more information."
;;
-h | --h*)
cat <<EOF
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
Members may be specified in a file named with @FILE.
EOF
exit $?
;;
-v | --v*)
echo "$me, version $scriptversion"
exit $?
;;
esac
if test $# -lt 3; then
func_error "you must specify a program, an action and an archive"
fi
AR=$1
shift
while :
do
if test $# -lt 2; then
func_error "you must specify a program, an action and an archive"
fi
case $1 in
-lib | -LIB \
| -ltcg | -LTCG \
| -machine* | -MACHINE* \
| -subsystem* | -SUBSYSTEM* \
| -verbose | -VERBOSE \
| -wx* | -WX* )
AR="$AR $1"
shift
;;
*)
action=$1
shift
break
;;
esac
done
orig_archive=$1
shift
func_file_conv "$orig_archive"
archive=$file
# strip leading dash in $action
action=${action#-}
delete=
extract=
list=
quick=
replace=
index=
create=
while test -n "$action"
do
case $action in
d*) delete=yes ;;
x*) extract=yes ;;
t*) list=yes ;;
q*) quick=yes ;;
r*) replace=yes ;;
s*) index=yes ;;
S*) ;; # the index is always updated implicitly
c*) create=yes ;;
u*) ;; # TODO: don't ignore the update modifier
v*) ;; # TODO: don't ignore the verbose modifier
*)
func_error "unknown action specified"
;;
esac
action=${action#?}
done
case $delete$extract$list$quick$replace,$index in
yes,* | ,yes)
;;
yesyes*)
func_error "more than one action specified"
;;
*)
func_error "no action specified"
;;
esac
if test -n "$delete"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
for member
do
case $1 in
@*)
func_at_file "${1#@}" -REMOVE "$archive"
;;
*)
func_file_conv "$1"
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
;;
esac
done
elif test -n "$extract"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
if test $# -gt 0; then
for member
do
case $1 in
@*)
func_at_file "${1#@}" -EXTRACT "$archive"
;;
*)
func_file_conv "$1"
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
;;
esac
done
else
$AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
do
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
done
fi
elif test -n "$quick$replace"; then
if test ! -f "$orig_archive"; then
if test -z "$create"; then
echo "$me: creating $orig_archive"
fi
orig_archive=
else
orig_archive=$archive
fi
for member
do
case $1 in
@*)
func_file_conv "${1#@}"
set x "$@" "@$file"
;;
*)
func_file_conv "$1"
set x "$@" "$file"
;;
esac
shift
shift
done
if test -n "$orig_archive"; then
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
else
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
fi
elif test -n "$list"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
$AR -NOLOGO -LIST "$archive" || exit $?
fi
......@@ -82,6 +82,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
......@@ -94,6 +97,11 @@
/* Version number of package */
#undef VERSION
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
......@@ -115,5 +123,5 @@
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define to `unsigned' if <sys/types.h> does not define. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
This diff is collapsed.
define([svnversion], esyscmd([sh -c "svnversion|tr -d '\n'"]))dnl
AC_INIT([tophat],[2.0.13],[tophat.cufflinks@gmail.com])
AC_INIT([tophat],[2.0.14],[tophat.cufflinks@gmail.com])
AC_DEFINE(SVN_REVISION, "svnversion", [SVN Revision])
AC_CONFIG_SRCDIR([config.h.in])
......@@ -38,8 +38,6 @@ if test -z "$BOOST_THREAD_LIBS"; then
fi
# BAM related:
ac_bam_path=samtools-0.1.18
BAM_LIB="-lbam"
......@@ -107,8 +105,8 @@ AS_IF([test "x$enable_debug" = xyes],
CFLAGS="${generic_CFLAGS} ${ext_CFLAGS} ${user_CFLAGS} ${debug_CFLAGS}"
CXXFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $BAM_CPPFLAGS -I./SeqAn-1.3"
LDFLAGS="$BOOST_LDFLAGS $BAM_LDFLAGS $user_LDFLAGS"
CXXFLAGS="$CXXFLAGS $BAM_CPPFLAGS $BOOST_CPPFLAGS -I./SeqAn-1.3"
LDFLAGS="$BAM_LDFLAGS $BOOST_LDFLAGS $user_LDFLAGS"
AM_INIT_AUTOMAKE([-Wall foreign tar-pax foreign])
......@@ -139,7 +137,7 @@ echo \
Install eprefix: ${exec_prefix}
See config.h for further configuration information.
Email <${PACKAGE_BUGREPORT}> with questions and bug reports.
Email bug reports to <${PACKAGE_BUGREPORT}>.
"
if test x"${PYTHON}" = x":" || ! test -x "${PYTHON}"; then
......
......@@ -720,51 +720,51 @@ libgc_a_SOURCES = \
prep_reads_SOURCES = prep_reads.cpp
prep_reads_LDADD = $(top_builddir)/src/libtophat.a $(BAM_LIB)
prep_reads_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
prep_reads_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
segment_juncs_SOURCES = segment_juncs.cpp
segment_juncs_LDADD = $(top_builddir)/src/libtophat.a $(BOOST_THREAD_LIBS) $(BOOST_SYSTEM_LIB) $(BAM_LIB)
segment_juncs_LDFLAGS = $(LDFLAGS) $(BOOST_LDFLAGS) $(BAM_LDFLAGS)
segment_juncs_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS) $(BOOST_LDFLAGS)
long_spanning_reads_SOURCES = long_spanning_reads.cpp
long_spanning_reads_LDADD = $(top_builddir)/src/libtophat.a $(BOOST_THREAD_LIBS) $(BOOST_SYSTEM_LIB) $(BAM_LIB)
long_spanning_reads_LDFLAGS = $(LDFLAGS) $(BOOST_LDFLAGS) $(BAM_LDFLAGS)
long_spanning_reads_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS) $(BOOST_LDFLAGS)
gtf_juncs_SOURCES = gtf_juncs.cpp
gtf_juncs_LDADD = $(top_builddir)/src/libtophat.a libgc.a $(BAM_LIB)
gtf_juncs_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
gtf_juncs_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
juncs_db_SOURCES = juncs_db.cpp
juncs_db_LDADD = $(top_builddir)/src/libtophat.a $(BAM_LIB)
juncs_db_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
juncs_db_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
tophat_reports_SOURCES = tophat_reports.cpp
tophat_reports_LDADD = $(top_builddir)/src/libtophat.a $(BOOST_THREAD_LIBS) $(BOOST_SYSTEM_LIB) $(BAM_LIB)
tophat_reports_LDFLAGS = $(LDFLAGS) $(BOOST_LDFLAGS) $(BAM_LDFLAGS)
tophat_reports_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS) $(BOOST_LDFLAGS)
fix_map_ordering_SOURCES = fix_map_ordering.cpp
fix_map_ordering_LDADD = $(top_builddir)/src/libtophat.a $(BAM_LIB)
fix_map_ordering_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
fix_map_ordering_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
bam2fastx_SOURCES = bam2fastx.cpp
bam2fastx_LDADD = $(top_builddir)/src/libgc.a $(BAM_LIB)
bam2fastx_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
bam2fastx_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
bam_merge_SOURCES = bam_merge.cpp
bam_merge_LDADD = $(top_builddir)/src/libtophat.a $(top_builddir)/src/libgc.a $(BAM_LIB)
bam_merge_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
bam_merge_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
sam_juncs_SOURCES = sam_juncs.cpp
sam_juncs_LDADD = $(top_builddir)/src/libtophat.a $(BAM_LIB)
sam_juncs_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
sam_juncs_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
map2gtf_SOURCES = map2gtf.cpp
map2gtf_LDADD = $(top_builddir)/src/libtophat.a libgc.a $(BAM_LIB)
map2gtf_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
map2gtf_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
gtf_to_fasta_SOURCES = GTFToFasta.cpp FastaTools.cpp
gtf_to_fasta_LDADD = $(top_builddir)/src/libtophat.a libgc.a $(BAM_LIB)
gtf_to_fasta_LDFLAGS = $(LDFLAGS) $(BAM_LDFLAGS)
gtf_to_fasta_LDFLAGS = $(BAM_LDFLAGS) $(LDFLAGS)
libbam_a_SOURCES =
......
This diff is collapsed.
......@@ -45,8 +45,15 @@ BamMerge::BamMerge(const vector<string>& bam_fnames,
}
if (bam_fnames.size() == file_offsets.size() &&
file_offsets[i] > 0)
bgzf_seek(fp->x.bam, file_offsets[i], SEEK_SET);
file_offsets[i] > 0) {
int64_t rseek=bgzf_seek(fp->x.bam, file_offsets[i], SEEK_SET);
//debugging
#if 1
if (rseek!=0) warn_msg("Warning: bgzf_seek() failed for %s\n",
fname);
#endif
}
bam1_t* b = bam_init1();
if (samread(fp, b) > 0) {
......@@ -54,13 +61,19 @@ BamMerge::BamMerge(const vector<string>& bam_fnames,
CBamLine brec(_lines.size(), b, fp->header);
_lines.push(brec);
}
else { bam_destroy1(b); }
}
else {
//debugging:
#if 1
warn_msg("Warning: no input BAM records found in %s (possibly due to wrong offset)\n",fname);
#endif
bam_destroy1(b);
}
} //read records from each file
if (_lines.size() == 0) {
warn_msg("Warning: no input BAM records found.\n");
exit(1);
}
/*if (_lines.size() == 0) {
warn_msg("Warning: no input BAM records found in input files.\n");
//exit(1);
}*/
}
BamMerge::~BamMerge()
......
......@@ -881,6 +881,18 @@ string guess_packer(const string& fname, bool use_all_cpus) {
}
else picmd="bzip2";
}
else if (fext=="xz") {
if (use_all_cpus && str_endsWith(zpacker,"pxz")) {
picmd=zpacker;
if (num_threads<2) picmd.append(" -T 1");
else {
picmd.append(" -T ");
str_appendInt(picmd, num_threads);
//picmd.append(" -cd");
}
}
else picmd="xz";
}
return picmd;
}
......
......@@ -17,6 +17,7 @@
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <boost/smart_ptr/make_shared.hpp>
#include <seqan/find.h>
#include <seqan/file.h>
......@@ -28,6 +29,8 @@
using namespace std;
QReadData QReadDataValue::Null;
char* FLineReader::nextLine() {
if(!file) return NULL;
if (pushed) { pushed=false; return buf; }
......@@ -528,7 +531,7 @@ bool ReadStream::next_read(QReadData& rdata) {
Read rf;
if (get_direct(rf)) {
uint64_t id = (uint64_t)atol(rf.name.c_str());
QReadData rdata(id, rf, last_b());
QReadData rdata=boost::make_shared<QReadDataValue>(id, rf, last_b());
read_pq.push(rdata);
}
}
......@@ -598,19 +601,19 @@ bool ReadStream::getRead(uint64_t r_id,
}
uint64_t id = (uint64_t)atol(read.name.c_str());
*/
if (rdata.id >= end_id)
if (rdata->id >= end_id)
return false;
if (rdata.id < begin_id)
if (rdata->id < begin_id)
continue; //silently skip until begin_id found
//does not trigger rProc->process() until begin_id
if (rdata.id == r_id)
if (rdata->id == r_id)
{
read=rdata.read; //it will be returned
read=rdata->read; //it will be returned
found=true;
}
else if (rdata.id > r_id)
else if (rdata->id > r_id)
{ //can't find it, went too far
//only happens when reads [mates] were removed for some reason
//read_pq.push(make_pair(id, read));
......@@ -639,23 +642,24 @@ bool ReadStream::getQRead(uint64_t r_id,
err_die("Error: ReadStream::getRead() called with out-of-order id#!");
last_id=r_id;
bool found=false;
qread.clear();
//qread.clear();
qread.reset();
while (!found) {
QReadData rdata;
if (!next_read(rdata))
break;
if (rdata.id >= end_id)
if (rdata->id >= end_id)
return false;
if (rdata.id < begin_id)
if (rdata->id < begin_id)
continue; //silently skip until begin_id found
//does not trigger rProc->process() until begin_id
if (rdata.id == r_id)
if (rdata->id == r_id)
{
qread=rdata; //it will be returned
found=true;
}
else if (rdata.id > r_id)
else if (rdata->id > r_id)
{ //can't find it, went too far
//only happens when reads [mates] were removed for some reason
//read_pq.push(make_pair(id, read));
......
......@@ -13,37 +13,17 @@
#include <sstream>
#include <queue>
#include <limits>
#include <boost/shared_ptr.hpp>
#include <seqan/sequence.h>
#include "common.h"
//#include "QReadData.h"
using std::string;
// Note: qualities are not currently used by TopHat
struct Read
{
Read()
{
//seq.reserve(MAX_READ_LEN);
//qual.reserve(MAX_READ_LEN);
}
string name;
string seq;
string alt_name;
string qual;
bool lengths_equal() { return seq.length() == qual.length(); }
void clear()
{
name.clear();
seq.clear();
qual.clear();
alt_name.clear();
}
};
void reverse_complement(string& seq);
string str_convert_color_to_bp(const string& color);
......@@ -134,23 +114,58 @@ public:
}
};
// Note: qualities are not currently used by TopHat
struct Read
{
Read()
{
//seq.reserve(MAX_READ_LEN);
//qual.reserve(MAX_READ_LEN);
}
string name;
string seq;
string alt_name;
string qual;
bool lengths_equal() { return seq.length() == qual.length(); }
void clear()
{
name.clear();
seq.clear();
qual.clear();
alt_name.clear();
}
};
ReadFormat skip_lines(FLineReader& fr);
bool next_fastx_read(FLineReader& fr, Read& read, ReadFormat rd_format=FASTQ,
FLineReader* frq=NULL);
#define READSTREAM_BUF_SIZE 500000
struct QReadData { //read data for the priority queue
struct QReadDataValue;
typedef boost::shared_ptr<QReadDataValue> QReadData;
struct QReadDataValue { //read data for the priority queue
uint64_t id;
Read read;
char trashCode; //ZT tag value
int8_t matenum; //mate number (1,2) 0 if unpaired
bool um_written;
QReadData():id(0),read(),trashCode(0), matenum(0), um_written(false) { }
QReadData(uint64_t rid, Read& rd, bam1_t* bd=NULL) {
static QReadData Null;
QReadDataValue():id(0),read(),trashCode(0), matenum(0), um_written(false) { }
QReadDataValue(uint64_t rid, const Read& rd, bam1_t* bd=NULL) {
init(rid, rd, bd);
}
void init(uint64_t rid, Read& rd, bam1_t* bd=NULL) {
void init(uint64_t rid, const Read& rd, bam1_t* bd=NULL) {
id=rid;
read=rd;
trashCode=0;
......@@ -177,6 +192,31 @@ struct QReadData { //read data for the priority queue
};
/*typedef struct { //read data for the priority queue
size_t refCount;
uint64_t id;
Read read;
char trashCode; //ZT tag value
int8_t matenum; //mate number (1,2) 0 if unpaired
bool um_written;
QReadDataValue():id(0),read(),trashCode(0), matenum(0), um_written(false),refCount(1) {}
QReadDataValue(uint64_t rid, Read& rd, bam1_t* bd=NULL);
~QReadDataValue();
void clear();
// void init(uint64_t rid, Read& rd, bam1_t* bd=NULL);
} QReadDataValue;*/
/*void deleteQReadDataValue() {
// nothing to do for the moment. May be interesting later to log deletion.
}*/
//callback struct for ReadStream::getRead() - called for each read in the stream
struct GetReadProc {
GBamWriter* um_out; //skipped (unmapped) reads will be written here
......@@ -192,36 +232,37 @@ struct GetReadProc {
um_out(bamw), unmapped_counter(um_counter), multimapped_counter(mm_counter),
u_unmapped_counter(u_um_counter), u_multimapped_counter(u_mm_counter)
{ }
virtual bool process(QReadData& rdata, bool& found) { //, bool is_unmapped) {
//should return True - if it returns FALSE it will cause getRead() to abort
//(stops looking for target readId in the stream) and to return false (="not found")
return true;
}
void writeUnmapped(QReadData& rdata) {
if (rdata.um_written) return;
string rname(rdata.read.alt_name);
void writeUnmapped(const QReadData& rdata) {
if (rdata->um_written) return;
string rname(rdata->read.alt_name);
size_t slash_pos=rname.rfind('/');
if (slash_pos!=string::npos && rname.length()-slash_pos<4)
rname.resize(slash_pos);
GBamRecord bamrec(rname.c_str(), -1, 0, false, rdata.read.seq.c_str(),
NULL, rdata.read.qual.c_str());
if (rdata.matenum) {
GBamRecord bamrec(rname.c_str(), -1, 0, false, rdata->read.seq.c_str(),
NULL, rdata->read.qual.c_str());
if (rdata->matenum) {
bamrec.set_flag(BAM_FPAIRED);
if (rdata.matenum==1) bamrec.set_flag(BAM_FREAD1);
if (rdata->matenum==1) bamrec.set_flag(BAM_FREAD1);
else bamrec.set_flag(BAM_FREAD2);
}
//if (found && um_code && !rdata.trashCode) {
//rdata.trashCode=um_code;
//if (found && um_code && !rdata->trashCode) {
//rdata->trashCode=um_code;
//}
if (rdata.trashCode) {
if (rdata->trashCode) {
//multi-mapped reads did not really QC-fail
//should also not be written to unmapped.bam
bamrec.add_aux("ZT", 'A', 1, (uint8_t*)&rdata.trashCode);
//if (rdata.trashCode!='M')
bamrec.add_aux("ZT", 'A', 1, (uint8_t*)&rdata->trashCode);
//if (rdata->trashCode!='M')
//bamrec.set_flag(BAM_FQCFAIL); //to be excluded from further processing?
}
um_out->write(&bamrec);
rdata.um_written=true;
rdata->um_written=true;
}
virtual ~GetReadProc() { }
......@@ -241,7 +282,7 @@ class ReadStream {
{
bool operator()(QReadData& lhs, QReadData& rhs)
{
return (lhs.id > rhs.id);
return (lhs->id > rhs->id);
}
};
FZPipe fstream;
......@@ -384,6 +425,7 @@ class ReadStream {
void rewind() {
fstream.rewind();
r_eof=false;
clear();
if (flseqs) {
flseqs->reset(fstream);
......@@ -393,18 +435,23 @@ class ReadStream {
flquals->reset(*fquals);
}
}
void seek(int64_t offset) {
clear();
fstream.seek(offset);
}
FILE* file() {
return fstream.file;
}
void clear() {
read_pq=std::priority_queue< QReadData,
std::vector<QReadData>,
ReadOrdering > ();