├── tools ├── README.md ├── util │ ├── FindProcess.h │ ├── SysTime.h │ ├── SComm.h │ ├── SysTime.cc │ ├── FindProcess.cc │ └── checkLock.c ├── visual │ ├── Eps.h │ ├── Eps.cc │ └── Color.h ├── analysis │ ├── MatchDynProg.h │ ├── MakeSixFrames.h │ ├── AlignProbability.h │ ├── SatsumaSummary.cc │ ├── ReverseSatsumaOut.cc │ ├── SatsumaAlign.cc │ ├── MakeSixFrames.cc │ ├── MultXCorr.h │ ├── SortSatsuma.cc │ ├── SplitSatsuma.cc │ ├── SatsumaToGFF.cc │ ├── DNAMatrix.h │ ├── SatsumaAlign.h │ ├── Coordinate.cc │ ├── Blosum.h │ ├── SatsumaToFasta.cc │ ├── ChainMatches.cc │ ├── SeqChunk.h │ └── MultiProtein.h ├── system │ └── BigFileDefines.h ├── src │ ├── Cola │ │ ├── AlignmentSet.cc │ │ ├── Cola.h │ │ ├── Cola.cc │ │ ├── IAligner.h │ │ ├── SWGAaligner.h │ │ ├── NSGAaligner.h │ │ ├── AlignmentSet.h │ │ ├── NOIAligner.cc │ │ ├── EditGraph.cc │ │ ├── SWGAaligner.cc │ │ ├── NSGAaligner.cc │ │ ├── NOIAligner.h │ │ ├── findColaSigDist.cc │ │ ├── AlignmentCola.h │ │ └── runCola.cc │ ├── AlignmentBlock.cc │ └── Papaya │ │ └── runPapayaCola.cc ├── base │ ├── ErrorHandling.h │ ├── ErrorHandling.cc │ ├── StringUtil.h │ ├── RandomStuff.h │ ├── FileParser.h │ └── SVector.h └── extern │ ├── RealFFT │ ├── test_settings.h │ ├── test_fnc.h │ ├── test_fnc.hpp │ ├── def.h │ ├── FFTRealSelect.hpp │ ├── FFTRealSelect.h │ ├── Array.h │ ├── Array.hpp │ ├── TestWhiteNoiseGen.h │ ├── TestHelperFixLen.h │ ├── FFTRealUseTrigo.hpp │ ├── TestHelperFixLen.hpp │ ├── TestHelperNormal.h │ ├── TestWhiteNoiseGen.hpp │ ├── FFTRealFixLenParam.h │ ├── DynArray.h │ ├── TestSpeed.h │ ├── FFTRealPassDirect.h │ ├── OscSinCos.h │ ├── FFTRealUseTrigo.h │ └── TestHelperNormal.hpp │ └── easel │ ├── esl_stats.h │ ├── esl_gumbel.h │ └── esl_stats.cc ├── test_SatsumaSynteny2 ├── util ├── SysTime.h └── SysTime.cc ├── .travis └── build.sh ├── analysis ├── MatchDynProg.h ├── AlignProbability.h ├── ProbTable.h ├── DNAMatrix.h ├── Blosum.h ├── ChainMatches.cc └── SeqChunk.h ├── system └── BigFileDefines.h ├── kmatch ├── matchresult.h ├── matchdump.cc └── KMatch.h ├── base ├── StringUtil.h └── FileParser.h ├── .travis.yml ├── bin └── satsuma_run.sh └── extern └── RealFFT ├── test_settings.h ├── test_fnc.h ├── test_fnc.hpp ├── def.h ├── FFTRealSelect.hpp ├── FFTRealSelect.h ├── Array.h ├── Array.hpp ├── TestWhiteNoiseGen.h ├── TestHelperFixLen.h ├── FFTRealUseTrigo.hpp ├── TestHelperNormal.h ├── TestHelperFixLen.hpp ├── TestWhiteNoiseGen.hpp ├── FFTRealFixLenParam.h ├── DynArray.h ├── TestSpeed.h ├── FFTRealPassDirect.h ├── OscSinCos.h ├── FFTRealUseTrigo.h └── TestHelperNormal.hpp /tools/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Satsuma2 tools directory 3 | -------------------------------------------------------------------------------- /test_SatsumaSynteny2: -------------------------------------------------------------------------------- 1 | 2 | export SATSUMA2_PATH=./bin 3 | 4 | bin/SatsumaSynteny2 -q samples/human.X.part.fasta -t samples/dog.X.part.fasta -o xcorr_sample_synt -slaves 2 -threads 2 5 | -------------------------------------------------------------------------------- /tools/util/FindProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef FINDPROCESS_H 2 | #define FINDPROCESS_H 3 | 4 | #include 5 | 6 | 7 | int getProcessCount(const string & p_processname); 8 | 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /util/SysTime.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYSTIME_H_ 2 | #define _SYSTIME_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | using namespace std; 10 | 11 | void GetTime(string & s); 12 | const string GetTimeStatic(bool bQuiet = false); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /.travis/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # Bash Script that builds project 3 | 4 | mkdir build 5 | cd build 6 | mkdir product 7 | cmake -DCMAKE_INSTALL_PREFIX=product .. ${CMAKE_OPTIONS} 8 | make all -j8 9 | make install 10 | 11 | tar cz product > satsuma2-${TRAVIS_OS_NAME}.tar.gz 12 | 13 | 14 | -------------------------------------------------------------------------------- /tools/util/SysTime.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYSTIME_H_ 2 | #define _SYSTIME_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | using namespace std; 10 | 11 | void GetTime(string & s); 12 | const string GetTimeStatic(bool bQuiet = false); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /analysis/MatchDynProg.h: -------------------------------------------------------------------------------- 1 | #ifndef MATCHDYNPROG_H_ 2 | #define MATCHDYNPROG_H_ 3 | 4 | #include "SequenceMatch.h" 5 | 6 | 7 | bool RunMatchDynProg(MultiMatches & out, const MultiMatches & in); 8 | bool RunMatchDynProgMult(MultiMatches & out, const MultiMatches & in); 9 | 10 | 11 | 12 | 13 | #endif //MATCHDYNPROG_H_ 14 | 15 | 16 | -------------------------------------------------------------------------------- /tools/visual/Eps.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GRAPHICS_EPS_H 3 | #define GRAPHICS_EPS_H 4 | 5 | using namespace std; 6 | 7 | #include 8 | 9 | 10 | void PrintEpsHeader( ostream& out, 11 | const float horizSize, 12 | const float vertSize, 13 | const float border ); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /tools/analysis/MatchDynProg.h: -------------------------------------------------------------------------------- 1 | #ifndef MATCHDYNPROG_H_ 2 | #define MATCHDYNPROG_H_ 3 | 4 | #include "SequenceMatch.h" 5 | 6 | 7 | bool RunMatchDynProg(MultiMatches & out, const MultiMatches & in, bool bSelf = false); 8 | bool RunMatchDynProgMult(MultiMatches & out, const MultiMatches & in); 9 | 10 | 11 | 12 | 13 | #endif //MATCHDYNPROG_H_ 14 | 15 | 16 | -------------------------------------------------------------------------------- /system/BigFileDefines.h: -------------------------------------------------------------------------------- 1 | #ifndef BIG_FILE_DEFINES_H 2 | #define BIG_FILE_DEFINES_H 3 | 4 | #ifdef __linux 5 | #ifndef _LARGEFILE64_SOURCE 6 | #define _LARGEFILE64_SOURCE 7 | #endif 8 | #define _FILE_OFFSET_BITS 64 9 | #define STAT_NAME stat64 10 | #else 11 | #define STAT_NAME stat 12 | #endif 13 | 14 | #endif //BIG_FILE_DEFINES_H 15 | -------------------------------------------------------------------------------- /tools/system/BigFileDefines.h: -------------------------------------------------------------------------------- 1 | #ifndef BIG_FILE_DEFINES_H 2 | #define BIG_FILE_DEFINES_H 3 | 4 | #ifdef __linux 5 | #ifndef _LARGEFILE64_SOURCE 6 | #define _LARGEFILE64_SOURCE 7 | #endif 8 | #define _FILE_OFFSET_BITS 64 9 | #define STAT_NAME stat64 10 | #else 11 | #define STAT_NAME stat 12 | #endif 13 | 14 | #endif //BIG_FILE_DEFINES_H 15 | -------------------------------------------------------------------------------- /tools/analysis/MakeSixFrames.h: -------------------------------------------------------------------------------- 1 | #ifndef MAKESIXFRAMES_H 2 | #define MAKESIXFRAMES_H 3 | 4 | 5 | 6 | #include "analysis/DNAVector.h" 7 | 8 | 9 | class MakeSixFrames 10 | { 11 | public: 12 | MakeSixFrames() {} 13 | 14 | void AllSixFrames(vecDNAVector & out, const vecDNAVector & in); 15 | void AllSixFrames(vecDNAVector & inout); 16 | 17 | }; 18 | 19 | 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /kmatch/matchresult.h: -------------------------------------------------------------------------------- 1 | #ifndef MATCHRESULT_INCLUDED 2 | #define MATCHRESULT_INCLUDED 1 3 | typedef struct { 4 | unsigned long int query_id; 5 | unsigned long int target_id; 6 | unsigned long int query_size; 7 | unsigned long int qstart; 8 | unsigned long int tstart; 9 | unsigned long int len; 10 | bool reverse; 11 | double prob; 12 | double ident; 13 | } t_result; 14 | #endif //MATCHRESULT_INCLUDED 15 | -------------------------------------------------------------------------------- /tools/src/Cola/AlignmentSet.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include "src/Cola/AlignmentSet.h" 6 | 7 | //===================================================================== 8 | 9 | void AlignmentSet::print(int outputType, double pValLimit, ostream& sout, int screenWidth) const { 10 | for( vector::const_iterator iter = alignments.begin(); iter != alignments.end(); iter++) { 11 | (*iter).print(outputType, pValLimit, sout, screenWidth); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /tools/base/ErrorHandling.h: -------------------------------------------------------------------------------- 1 | #ifndef ERRORHANDLING_H_ 2 | #define ERRORHANDLING_H_ 3 | 4 | using namespace std; 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | class SException 11 | { 12 | public: 13 | SException(const string & info, const string & type = "") { 14 | m_type = type; 15 | m_info = info; 16 | cout << "EXCEPTION: " << type << " " << info << endl; 17 | } 18 | 19 | 20 | void Throw(); 21 | 22 | private: 23 | string m_type; 24 | string m_info; 25 | 26 | }; 27 | 28 | 29 | inline void ThrowError(const string & info, const string & type) { 30 | SException up(info, type); 31 | up.Throw(); 32 | } 33 | 34 | 35 | #endif //ERRORHANDLING_H_ 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /tools/src/Cola/Cola.h: -------------------------------------------------------------------------------- 1 | #ifndef _COLA_H_ 2 | #define _COLA_H_ 3 | 4 | #include "AlignmentCola.h" 5 | #include "AlignerParams.h" 6 | 7 | //===================================================================== 8 | 9 | /** 10 | * Factory class used for obtaining one of the aligner types: 11 | * NSGAaligner, NSaligner, SWGAaligner, and SWaligner 12 | */ 13 | class Cola 14 | { 15 | public: 16 | /** 17 | * @return pointer to the requested aligner object 18 | */ 19 | const AlignmentCola& createAlignment(const DNAVector& tSeq, const DNAVector& qSeq, 20 | AlignerParams params); 21 | 22 | const AlignmentCola getAlignment() { return latestAlignment; } 23 | 24 | private: 25 | AlignmentCola latestAlignment; 26 | }; 27 | 28 | #endif //_COLA_H_ 29 | -------------------------------------------------------------------------------- /tools/visual/Eps.cc: -------------------------------------------------------------------------------- 1 | #include "Eps.h" 2 | 3 | void PrintEpsHeader( ostream& out, 4 | const float horizSize, 5 | const float vertSize, 6 | const float border ) 7 | { 8 | const float leftBoundbox = 0; 9 | const float rightBoundbox = border + horizSize + border; 10 | const float bottomBoundbox = 0; 11 | const float topBoundbox = border + vertSize + border; 12 | 13 | out.setf( ios::fixed ); 14 | 15 | out << "%!PS-Adobe-3.0 EPSF-3.0\n" 16 | << "%%BoundingBox: " 17 | << leftBoundbox << " " << bottomBoundbox << " " 18 | << rightBoundbox << " " << topBoundbox 19 | << "\n"; 20 | 21 | // Translate boundbox to origin. 22 | out << border << " " << border << " translate\n"; 23 | } 24 | -------------------------------------------------------------------------------- /tools/util/SComm.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCOMM_H_ 2 | #define _SCOMM_H_ 3 | 4 | /* the port users will be connecting to */ 5 | #define MYPORT 3491 6 | 7 | class SCommTransmitter 8 | { 9 | public: 10 | virtual ~SCommTransmitter() {} 11 | 12 | virtual bool SendWait(const char * message) = 0; 13 | 14 | }; 15 | 16 | 17 | class SCommReceiver 18 | { 19 | public: 20 | virtual ~SCommReceiver() {} 21 | 22 | // Make sure there is enough space in the buffer! 23 | virtual bool Get(char * message, int bufSize) = 0; 24 | virtual bool IsFatal() = 0; 25 | }; 26 | 27 | // This is how to get an actual instance 28 | SCommTransmitter * GetTransmitter(int port = MYPORT); 29 | SCommReceiver * GetReceiver(const char * serverName, int port = MYPORT); 30 | 31 | bool GetHostName(char * host, int bufSize); 32 | 33 | #endif 34 | 35 | 36 | -------------------------------------------------------------------------------- /kmatch/matchdump.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #define __STDC_LIMIT_MACROS 6 | #include 7 | #include 8 | #include "matchresult.h" 9 | 10 | #include "KMatch.h" 11 | #include 12 | #include 13 | #include 14 | 15 | int main(int argc, char ** argv){ 16 | 17 | if (argc!=2) { 18 | std::cout<<"Usage: "< 3 | 4 | 5 | //#include 6 | 7 | void print_trace(FILE *out, const char *file, int line) 8 | { 9 | /* const size_t max_depth = 100; 10 | size_t stack_depth; 11 | void *stack_addrs[max_depth]; 12 | char **stack_strings; 13 | 14 | stack_depth = backtrace(stack_addrs, max_depth); 15 | stack_strings = backtrace_symbols(stack_addrs, stack_depth); 16 | 17 | fprintf(out, "Call stack from %s:%d:\n", file, line); 18 | 19 | for (size_t i = 1; i < stack_depth; i++) { 20 | fprintf(out, " %s\n", stack_strings[i]); 21 | } 22 | free(stack_strings); // malloc()ed by backtrace_symbols 23 | fflush(out);*/ 24 | } 25 | 26 | 27 | void SException::Throw() { 28 | print_trace(stdout, "", -1); 29 | 30 | throw *this; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /analysis/AlignProbability.h: -------------------------------------------------------------------------------- 1 | #ifndef _ALIGNPROBABILITY_H_ 2 | #define _ALIGNPROBABILITY_H_ 3 | 4 | 5 | 6 | class DNAVector; 7 | 8 | 9 | 10 | double GetMatchProbability(const DNAVector & target, 11 | const DNAVector & query, 12 | int startTarget, 13 | int startQuery, 14 | int length, 15 | double targetSize); 16 | 17 | 18 | double GetMatchProbabilityEx(double & ident, 19 | const DNAVector & target, 20 | const DNAVector & query, 21 | int startTarget, 22 | int startQuery, 23 | int length, 24 | double targetSize); 25 | 26 | 27 | double GetRawScore(double ident, 28 | int len, 29 | int tLen, 30 | double gcQuery, 31 | double gcTarget); 32 | 33 | double GetPValueForColaScore(double ident, 34 | double length, 35 | int qLen, 36 | int tLen); 37 | 38 | 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /tools/analysis/AlignProbability.h: -------------------------------------------------------------------------------- 1 | #ifndef _ALIGNPROBABILITY_H_ 2 | #define _ALIGNPROBABILITY_H_ 3 | 4 | 5 | 6 | class DNAVector; 7 | 8 | 9 | 10 | double GetMatchProbability(const DNAVector & target, 11 | const DNAVector & query, 12 | int startTarget, 13 | int startQuery, 14 | int length, 15 | double targetSize); 16 | 17 | 18 | double GetMatchProbabilityEx(double & ident, 19 | const DNAVector & target, 20 | const DNAVector & query, 21 | int startTarget, 22 | int startQuery, 23 | int length, 24 | double targetSize); 25 | 26 | 27 | double GetRawScore(double ident, 28 | int len, 29 | int tLen, 30 | double gcQuery, 31 | double gcTarget); 32 | 33 | double GetPValueForColaScore(double ident, 34 | double length, 35 | int qLen, 36 | int tLen); 37 | 38 | 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /tools/src/Cola/Cola.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include "Cola.h" 6 | #include "NSGAaligner.h" 7 | 8 | const AlignmentCola& Cola::createAlignment(const DNAVector& tSeq, const DNAVector& qSeq, 9 | AlignerParams params) { 10 | IAligner* aligner; 11 | switch(params.getType()) { 12 | case NSGA: 13 | aligner = new NSGAaligner(tSeq, qSeq, params); 14 | break; 15 | case NS: 16 | aligner = new NSaligner(tSeq, qSeq, params); 17 | break; 18 | case SWGA: 19 | aligner = new SWGAaligner(tSeq, qSeq, params); 20 | break; 21 | case SW: 22 | aligner = new SWGAaligner(tSeq, qSeq, params); 23 | break; 24 | default: 25 | //TODO error message 26 | aligner = new NSGAaligner(tSeq, qSeq, params); 27 | } 28 | latestAlignment = aligner->align(); 29 | delete aligner; 30 | return latestAlignment; 31 | } 32 | -------------------------------------------------------------------------------- /base/StringUtil.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef STRINGUTIL_H 3 | #define STRINGUTIL_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | string After(string &s, string &t); 13 | string Before(string &s, string &t); 14 | bool Contains(string &s, string &t); 15 | 16 | string After(string &s, char *t); 17 | string Before(string &s, char *t); 18 | bool Contains(string &s, char *t); 19 | 20 | bool ContainsAt(string &s, string &t, int at); 21 | 22 | int PositionAfter(string &in, string& s, int startSearchAt); 23 | 24 | inline string Stringify(int x) 25 | { 26 | ostringstream out; 27 | out << x; 28 | return (out.str()); 29 | } 30 | 31 | 32 | int Tokenize( const string &a_string, 33 | vector &separators, 34 | vector &tokens ); 35 | 36 | 37 | int Tokenize( const string &a_string, 38 | vector &tokens ); 39 | 40 | 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /tools/base/StringUtil.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef STRINGUTIL_H 3 | #define STRINGUTIL_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | string After(string &s, string &t); 13 | string Before(string &s, string &t); 14 | bool Contains(string &s, string &t); 15 | 16 | string After(string &s, char *t); 17 | string Before(string &s, char *t); 18 | bool Contains(string &s, char *t); 19 | 20 | bool ContainsAt(string &s, string &t, int at); 21 | 22 | int PositionAfter(string &in, string& s, int startSearchAt); 23 | 24 | inline string Stringify(int x) 25 | { 26 | ostringstream out; 27 | out << x; 28 | return (out.str()); 29 | } 30 | 31 | 32 | int Tokenize( const string &a_string, 33 | vector &separators, 34 | vector &tokens ); 35 | 36 | 37 | int Tokenize( const string &a_string, 38 | vector &tokens ); 39 | 40 | 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /tools/base/RandomStuff.h: -------------------------------------------------------------------------------- 1 | #ifndef RANDOMSTUFF_H_ 2 | #define RANDOMSTUFF_H_ 3 | 4 | #include 5 | #include "base/SVector.h" 6 | 7 | inline long long RandomInt(long long n) 8 | { 9 | long long r = ((long long)( rand( ) ) << 31 ) ^ (long long)( rand( ) ); 10 | //cout << "r=" << r; 11 | r = r % n; 12 | //cout << " " << r << endl; 13 | return r; 14 | } 15 | 16 | inline double RandomFloat(double n) 17 | { 18 | long long r = ((long long)( rand( ) ) << 31 ) ^ (long long)( rand( ) ); 19 | //cout << "r=" << r; 20 | r = r % 0x7FFFFFFF; 21 | //cout << " " << r << endl; 22 | return n*((double)r)/(double)0x7FFFFFFF; 23 | } 24 | 25 | 26 | 27 | 28 | template 29 | void SRandomize(svec& v) 30 | { 31 | random_shuffle(v.begin(), v.end()); 32 | } 33 | 34 | template 35 | void Randomize(vector& v) 36 | { 37 | random_shuffle(v.begin(), v.end()); 38 | } 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | #endif //RANDOMSTUFF_H_ 47 | 48 | -------------------------------------------------------------------------------- /tools/src/Cola/IAligner.h: -------------------------------------------------------------------------------- 1 | #ifndef _IALIGNER_H_ 2 | #define _IALIGNER_H_ 3 | 4 | #include "AlignmentCola.h" 5 | 6 | //===================================================================== 7 | /** 8 | * Interface for Aligner objects (NSGAaligner, NSaligner, SWGAaligner, and SWaligner) 9 | */ 10 | class IAligner 11 | { 12 | public: 13 | virtual ~IAligner() {} 14 | /** 15 | * main function to call for performing the alignment. 16 | * @return Returns the Alignment object which contains the alignment strings and other data 17 | */ 18 | virtual const AlignmentCola& align() = 0; 19 | 20 | /** Returns the alignment object which contains the alignment strings and info **/ 21 | virtual const AlignmentCola& getAlignment() = 0; 22 | 23 | /** Returns the target sequence used for the alignment */ 24 | virtual const DNAVector& getTargetSeq() = 0; 25 | 26 | /** Returns the query sequence used for the alignment */ 27 | virtual const DNAVector& getQuerySeq() = 0; 28 | }; 29 | 30 | 31 | 32 | #endif //_IALIGNER_H_ 33 | -------------------------------------------------------------------------------- /tools/analysis/SatsumaSummary.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "base/CommandLineParser.h" 3 | #include "base/FileParser.h" 4 | 5 | 6 | 7 | int main( int argc, char** argv ) 8 | { 9 | 10 | commandArg fileCmmd("-i","input file"); 11 | commandLineParser P(argc,argv); 12 | P.SetDescription("Median length and identity."); 13 | P.registerArg(fileCmmd); 14 | 15 | P.parse(); 16 | 17 | string fileName = P.GetStringValueFor(fileCmmd); 18 | 19 | 20 | //comment. ??? 21 | FlatFileParser parser; 22 | 23 | parser.Open(fileName); 24 | 25 | svec ident; 26 | svec len; 27 | 28 | int sum = 0; 29 | 30 | while (parser.ParseLine()) { 31 | len.push_back(parser.AsInt(2)-parser.AsInt(1)); 32 | ident.push_back(parser.AsFloat(6)); 33 | sum += parser.AsInt(2) - parser.AsInt(1); 34 | } 35 | 36 | cout << "Total sequence: " << sum << endl; 37 | cout << "Median length: " << len[len.isize()/2] << endl; 38 | cout << "Median identity: " << ident[ident.isize()/2] << endl; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /tools/analysis/ReverseSatsumaOut.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../base/CommandLineParser.h" 3 | //#include "../base/FileParser.h" 4 | 5 | 6 | 7 | int main( int argc, char** argv ) 8 | { 9 | 10 | commandArg fileCmmd("-i","input satsuma file"); 11 | commandLineParser P(argc,argv); 12 | P.SetDescription("Swaps query and target columns in the satsuma output."); 13 | P.registerArg(fileCmmd); 14 | 15 | P.parse(); 16 | 17 | string fileName = P.GetStringValueFor(fileCmmd); 18 | 19 | 20 | FlatFileParser parser; 21 | 22 | parser.Open(fileName); 23 | 24 | while (parser.ParseLine()) { 25 | if (parser.GetItemCount() == 0) 26 | continue; 27 | cout << parser.AsString(3) << "\t"; 28 | cout << parser.AsInt(4) << "\t"; 29 | cout << parser.AsInt(5) << "\t"; 30 | cout << parser.AsString(0) << "\t"; 31 | cout << parser.AsInt(1) << "\t"; 32 | cout << parser.AsInt(2) << "\t"; 33 | cout << parser.AsString(6) << "\t"; 34 | cout << parser.AsString(7) << endl; 35 | } 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /tools/src/Cola/SWGAaligner.h: -------------------------------------------------------------------------------- 1 | #ifndef _SWGAALIGNER_H_ 2 | #define _SWGAALIGNER_H_ 3 | 4 | #include "NSaligner.h" 5 | 6 | class SWGAaligner: public NSaligner 7 | { 8 | public: 9 | /** 10 | * @param[in] The target sequence 11 | * @param[in] The query sequence 12 | * Note that the targetSeq and querySeq are not copied 13 | * N.B. The depth is set as two here to use three elements for each cell 14 | * one for the vertical, once for horizontal, and one for the diagonal move 15 | */ 16 | SWGAaligner(const DNAVector& tSeq, const DNAVector& qSeq, 17 | const AlignerParams& p = AlignerParams(SWGA), int maxD = 2) 18 | :NSaligner(tSeq, qSeq, p, maxD) {} 19 | 20 | ~SWGAaligner() {} 21 | 22 | protected: 23 | /** 24 | * Overrides the visitNode function in the parent class (i.e. NSaligner) 25 | * @param[in] The node to be visited 26 | * @param[in] Index of column that should be checkpointed in current iteration 27 | */ 28 | virtual void visitNode(EditGraphNode* currNode, int currCheckpointColIndex); 29 | }; 30 | 31 | 32 | #endif //_SWGAALIGNER_H_ 33 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c++ 2 | sudo: false 3 | jobs: 4 | include: 5 | - stage: compile osx 6 | os: osx 7 | osx_image: xcode10.1 8 | before_install: 9 | - brew install gcc@6 10 | env: 11 | - CMAKE_OPTIONS="-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6" 12 | deploy: 13 | provider: releases 14 | api_key: $GITHUB_TOKEN 15 | draft: true 16 | skip_cleanup: true 17 | file: build/satsuma2-${TRAVIS_OS_NAME}.tar.gz 18 | # on: 19 | # tags: true 20 | - stage: compile linux 21 | os: linux 22 | addons: 23 | apt: 24 | sources: 25 | - ubuntu-toolchain-r-test 26 | packages: 27 | - g++-6 28 | env: 29 | - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" 30 | - CMAKE_OPTIONS="-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6" 31 | deploy: 32 | - provider: releases 33 | api_key: $GITHUB_TOKEN 34 | draft: false 35 | skip_cleanup: true 36 | file: build/satsuma2-${TRAVIS_OS_NAME}.tar.gz 37 | # on: 38 | # tags: true 39 | 40 | before_install: 41 | - eval "${MATRIX_EVAL}" 42 | script: 43 | - ".travis/build.sh" 44 | -------------------------------------------------------------------------------- /analysis/ProbTable.h: -------------------------------------------------------------------------------- 1 | #ifndef _PROBTABLE_H_ 2 | #define _PROBTABLE_H_ 3 | #ifndef FORCE_DEBUG 4 | #define NDEBUG 5 | #endif 6 | 7 | #include 8 | #include "DNAVector.h" 9 | 10 | class ProbTable 11 | { 12 | public: 13 | ProbTable(); 14 | ProbTable(double targetSize, double cutoff); 15 | void Setup(double targetSize, double cutoff); 16 | bool IsGood(int length, double ident, double ident_expect); 17 | double GetMatchProbabilityRaw(int length, double ident, double ident_expect, double targetSize); 18 | double GetMatchProbability(double & ident, 19 | const DNAVector & target, 20 | const DNAVector & query, 21 | int startTarget, 22 | int startQuery, 23 | int length); 24 | private: 25 | int ExpectToIndex(double ident_expect); 26 | 27 | std::vector< std::vector < double > > m_table; 28 | 29 | double CDF(double x, double m, double s); 30 | double Sigma(double p, int N); 31 | double GCAdjustExpect(double gc, int N, double gc_target); 32 | 33 | double m_size; 34 | double m_cutoff; 35 | double dna_id_table[128][128]; 36 | double dna_gc_table[128]; 37 | 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /util/SysTime.cc: -------------------------------------------------------------------------------- 1 | #include "../util/SysTime.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | // this const was part of a class... 9 | const int getTimeOfDayBufferLength = 27; 10 | 11 | // this function was a static method in that class... 12 | char* GetTimeOfDayInt(char* buffer, int bufferLength) 13 | { 14 | if (bufferLength 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | // this const was part of a class... 10 | const int getTimeOfDayBufferLength = 27; 11 | 12 | // this function was a static method in that class... 13 | char* GetTimeOfDayInt(char* buffer, int bufferLength) 14 | { 15 | if (bufferLength 7 | # mem should be in Gb, ie. 100Gb = 100 8 | 9 | # no submission system, processes are run locally either synchronously or asynchronously 10 | if [ "$6" -eq 1 ]; then 11 | eval "$2" 12 | else 13 | eval "$2" & 14 | fi 15 | 16 | ############################################################################################################## 17 | ## For the sections below you will need to change the queue name (QueueName) to one existing on your system ## 18 | ############################################################################################################## 19 | 20 | # qsub (PBS systems) 21 | #echo "cd $1; $2" | qsub -V -qQueueName -l ncpus=$3,mem=$4G -N $5 22 | 23 | # bsub (LSF systems) 24 | #mem=`expr $4 + 1000` 25 | #bsub -o ${5}.log -J $5 -n $3 -q QueueName -R "rusage[mem=$mem]" "$2" 26 | 27 | # SLURM systems 28 | #echo "#!/bin/sh" > slurm_tmp.sh 29 | #echo srun $2 >> slurm_tmp.sh 30 | #sbatch -p QueueName -c $3 -J $5 -o ${5}.log --mem ${4}G slurm_tmp.sh 31 | -------------------------------------------------------------------------------- /tools/analysis/SatsumaAlign.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "analysis/SatsumaAlign.h" 3 | #include "base/FileParser.h" 4 | 5 | 6 | void SAlignVec::Read(const string & fileName) 7 | { 8 | int chunk = 65536; 9 | 10 | FlatFileParser parser; 11 | 12 | parser.Open(fileName); 13 | 14 | while (parser.ParseLine()) { 15 | if (m_count >= m_aligns.isize()) { 16 | m_aligns.resize(m_count + chunk); 17 | } 18 | m_aligns[m_count].Set(parser.AsString(0), 19 | parser.AsString(3), 20 | parser.AsInt(1), 21 | parser.AsInt(2), 22 | parser.AsInt(4), 23 | parser.AsInt(5), 24 | parser.AsFloat(6), 25 | parser.AsString(7)); 26 | 27 | m_count++; 28 | 29 | } 30 | m_aligns.resize(m_count); 31 | } 32 | 33 | void SAlignVec::Write(const string & fileName) 34 | { 35 | 36 | FILE * pOut = fopen(fileName.c_str(), "w"); 37 | 38 | for (int i=0; i sizeA) 17 | sizeA = sizeB; 18 | 19 | int b = 1; 20 | while (b < sizeA) { 21 | b *= 2; 22 | } 23 | // Take care of 0 padding to avoid wrap-around. 24 | b *= 2; 25 | 26 | if (b < 512) 27 | b = 512; 28 | //cout << "Full size=" << b << endl; 29 | return b; 30 | } 31 | 32 | 33 | void CrossCorrelate(svec & out, const CCSignal & one, const CCSignal & two) { 34 | int i = Index(one.GetFullSize()); 35 | if (i >= m_xc.isize()) { 36 | cout << "ERROR! FFT size not implemented: " << one.GetFullSize() << endl; 37 | throw; 38 | return; 39 | } 40 | 41 | //cout << "Start XC, i=" << i << endl; 42 | m_xc[i].CrossCorrelate(out, one, two); 43 | //cout << "done." << endl; 44 | } 45 | 46 | 47 | 48 | private: 49 | int Index(int size) { 50 | int i = 0; 51 | while (size > 2) { 52 | i++; 53 | size /= 2; 54 | } 55 | return i; 56 | } 57 | 58 | svec m_xc; 59 | 60 | }; 61 | 62 | 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /tools/src/Cola/AlignmentSet.h: -------------------------------------------------------------------------------- 1 | #ifndef _ALIGNMENTSET_H_ 2 | #define _ALIGNMENTSET_H_ 3 | 4 | #include "AlignmentCola.h" 5 | 6 | #define MISMATCH_PENALTY -7.0 7 | 8 | //===================================================================== 9 | /** 10 | * NOICOLA - None Overlapping Iterative - Contiguous Optimal Local Aligner: 11 | * The local alignment algorithm, Cola is ran on given regions to iteratively 12 | * find the best scoring none-overlapping alignments. 13 | */ 14 | class AlignmentSet 15 | { 16 | public: 17 | /** 18 | * Constructor just initialises the alignments 19 | */ 20 | AlignmentSet():alignments() {} 21 | 22 | /** 23 | * Add an alignment to the list of alignments held by the set 24 | * A const reference to the alignment is accepted and used to create copy to keep 25 | */ 26 | void add(const AlignmentCola& algn) { alignments.push_back(AlignmentCola(algn));} 27 | 28 | /** 29 | * Return the Nth alignment in the order that they were created 30 | */ 31 | const AlignmentCola& getNthAlignmentCola(int rank) const { return alignments[rank-1]; } 32 | 33 | /** 34 | * Use to print the alignment and a summary of the details 35 | * @param outputType: choose what to print 0- full alignment 1-info in CSV format 36 | */ 37 | void print(int outputType, double pValLimit, ostream& sout, int screenWidth) const; 38 | 39 | private: 40 | vector alignments; /// Vector containing alignments in the order they were found 41 | }; 42 | 43 | 44 | 45 | #endif //_NOICOLA_H_ 46 | 47 | -------------------------------------------------------------------------------- /tools/analysis/SortSatsuma.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../base/CommandLineParser.h" 3 | #include "../base/FileParser.h" 4 | 5 | 6 | class Line 7 | { 8 | public: 9 | Line() {} 10 | 11 | void Set(const string & s, 12 | const string & chr, 13 | int start) { 14 | m_start = start; 15 | m_chr = chr; 16 | m_line = s; 17 | } 18 | 19 | 20 | bool operator < (const Line & l) const { 21 | if (m_chr != l.m_chr) 22 | return (m_chr < l.m_chr); 23 | return (m_start < l.m_start); 24 | } 25 | 26 | const string & GetLine() const {return m_line;} 27 | 28 | private: 29 | string m_line; 30 | string m_chr; 31 | int m_start; 32 | 33 | 34 | }; 35 | 36 | 37 | int main( int argc, char** argv ) 38 | { 39 | 40 | commandArg fileCmmd("-i","input file"); 41 | commandLineParser P(argc,argv); 42 | P.SetDescription("Sorts a Satsuma file by chr & start."); 43 | P.registerArg(fileCmmd); 44 | 45 | P.parse(); 46 | 47 | string fileName = P.GetStringValueFor(fileCmmd); 48 | 49 | 50 | //comment. ??? 51 | FlatFileParser parser; 52 | 53 | parser.Open(fileName); 54 | 55 | svec line; 56 | 57 | int k = 0; 58 | 59 | while (parser.ParseLine()) { 60 | if (line.isize() <= k) 61 | line.resize(k+2000000); 62 | line[k].Set(parser.Line(), parser.AsString(0), parser.AsInt(1)); 63 | k++; 64 | 65 | } 66 | 67 | line.resize(k); 68 | 69 | Sort(line); 70 | for (int i=0; i 2 | #include "base/CommandLineParser.h" 3 | #include "base/FileParser.h" 4 | 5 | 6 | 7 | 8 | int main( int argc, char** argv ) 9 | { 10 | 11 | commandArg fileCmmd("-i","input file"); 12 | commandArg nCmmd("-n","how many"); 13 | commandLineParser P(argc,argv); 14 | P.SetDescription("Splits a Satsuma file into equal chunks."); 15 | P.registerArg(fileCmmd); 16 | P.registerArg(nCmmd); 17 | 18 | P.parse(); 19 | 20 | string fileName = P.GetStringValueFor(fileCmmd); 21 | 22 | int n = P.GetIntValueFor(nCmmd); 23 | 24 | 25 | //comment. ??? 26 | FlatFileParser parser; 27 | 28 | parser.Open(fileName); 29 | 30 | 31 | svec all; 32 | 33 | while (parser.ParseLine()) { 34 | if (parser.GetItemCount() == 0) 35 | continue; 36 | all.push_back(parser.Line()); 37 | } 38 | int cc = all.isize() / n; 39 | 40 | int k = 0; 41 | FILE * pOut = NULL; 42 | 43 | for (int i=0; i 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | class StringParser 17 | { 18 | public: 19 | StringParser(); 20 | 21 | virtual ~StringParser(); 22 | 23 | void SetLine(const string & line); 24 | void SetLine(const string & line, const string & delimiter); 25 | 26 | int GetItemCount(); 27 | 28 | bool IsString(int index); 29 | bool IsInt(int index); 30 | bool IsFloat(int index); 31 | 32 | 33 | const string & AsString(int index); 34 | char AsChar(int index); 35 | int AsInt(int index); 36 | double AsFloat(int index); 37 | 38 | 39 | private: 40 | CMAsciiReadFileStream m_file; 41 | vector m_items; 42 | 43 | }; 44 | 45 | 46 | 47 | 48 | 49 | 50 | class FlatFileParser : public StringParser 51 | { 52 | public: 53 | FlatFileParser(); 54 | FlatFileParser(const string & fileName); 55 | 56 | virtual ~FlatFileParser(); 57 | 58 | void Open(const string & fileName); 59 | bool Exists(const string &fileName); 60 | 61 | bool ParseLine(); 62 | bool IsEndOfFile(); 63 | 64 | bool GetLine(string & line); 65 | const string & Line() const {return m_line;} 66 | 67 | void LoadVector(string &filename, vector &elements); 68 | void LoadSet(string &filename, set &elements); 69 | 70 | private: 71 | CMAsciiReadFileStream m_file; 72 | string m_line; 73 | }; 74 | 75 | 76 | 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /extern/RealFFT/test_settings.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | test_settings.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (test_settings_HEADER_INCLUDED) 27 | #define test_settings_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | // #undef this label to avoid speed test compilation. 37 | #define test_settings_SPEED_TEST_ENABLED 38 | 39 | 40 | 41 | #endif // test_settings_HEADER_INCLUDED 42 | 43 | 44 | 45 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 46 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/test_settings.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | test_settings.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (test_settings_HEADER_INCLUDED) 27 | #define test_settings_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | // #undef this label to avoid speed test compilation. 37 | #define test_settings_SPEED_TEST_ENABLED 38 | 39 | 40 | 41 | #endif // test_settings_HEADER_INCLUDED 42 | 43 | 44 | 45 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 46 | -------------------------------------------------------------------------------- /tools/analysis/SatsumaToGFF.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../base/CommandLineParser.h" 3 | 4 | int main( int argc, char** argv ) 5 | { 6 | 7 | commandArg fileCmmd("-i","input satsuma file"); 8 | commandArg tCmmd("-t","output coordinates based on target", false); 9 | commandLineParser P(argc,argv); 10 | P.SetDescription("Generates a GFF3 file from a satsuma file."); 11 | P.registerArg(fileCmmd); 12 | P.registerArg(tCmmd); 13 | 14 | P.parse(); 15 | 16 | string fileName = P.GetStringValueFor(fileCmmd); 17 | bool bTarget = P.GetBoolValueFor(tCmmd); 18 | 19 | FlatFileParser parser; 20 | 21 | parser.Open(fileName); 22 | 23 | int count = 1; 24 | 25 | while (parser.ParseLine()) { 26 | if (parser.GetItemCount() == 0) 27 | continue; 28 | if (bTarget) { 29 | // convert from 0-based coords to GFF3 1-based coords 30 | // target based 31 | cout << parser.AsString(0) << "\tSatsuma\tblock\t" << parser.AsInt(1) + 1 << "\t" << parser.AsInt(2) << "\t\t" << parser.AsString(7) << "\t.\t"; 32 | cout << "ID=sblock_" << to_string(count) << ";Name=sblock_" << to_string(count) << ";Target=" << parser.AsString(3) << endl; 33 | } else { 34 | // query based 35 | cout << parser.AsString(3) << "\tSatsuma\tblock\t" << parser.AsInt(4) + 1 << "\t" << parser.AsInt(5) << "\t\t" << parser.AsString(7) << "\t.\t"; 36 | cout << "ID=sblock_" << to_string(count) << ";Name=sblock_" << to_string(count) << ";Target=" << parser.AsString(0) << endl; 37 | } 38 | 39 | count++; 40 | 41 | } 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /tools/extern/easel/esl_stats.h: -------------------------------------------------------------------------------- 1 | /* Foundation, miscellenea for the statistics modules. 2 | */ 3 | #ifndef eslSTATS_INCLUDED 4 | #define eslSTATS_INCLUDED 5 | 6 | /* 1. Summary statistics calculations */ 7 | extern int esl_stats_DMean(const double *x, int n, double *opt_mean, double *opt_var); 8 | extern int esl_stats_FMean(const float *x, int n, double *opt_mean, double *opt_var); 9 | extern int esl_stats_IMean(const int *x, int n, double *opt_mean, double *opt_var); 10 | 11 | /* 2. Special functions */ 12 | extern int esl_stats_LogGamma(double x, double *ret_answer); 13 | extern int esl_stats_Psi(double x, double *ret_answer); 14 | extern int esl_stats_IncompleteGamma(double a, double x, double *ret_pax, double *ret_qax); 15 | 16 | /* 3. Standard statistical tests */ 17 | extern int esl_stats_GTest(int ca, int na, int cb, int nb, double *ret_G, double *ret_P); 18 | extern int esl_stats_ChiSquaredTest(int v, double x, double *ret_answer); 19 | 20 | /* 4. Data fitting */ 21 | extern int esl_stats_LinearRegression(const double *x, const double *y, const double *sigma, int n, 22 | double *opt_a, double *opt_b, 23 | double *opt_sigma_a, double *opt_sigma_b, double *opt_cov_ab, 24 | double *opt_cc, double *opt_Q); 25 | #endif /*eslSTATS_INCLUDED*/ 26 | /***************************************************************** 27 | * @LICENSE@ 28 | * 29 | * SVN $Id: esl_stats.h 771 2012-06-11 12:53:13Z eddys $ 30 | * SVN $URL: https://svn.janelia.org/eddylab/eddys/easel/trunk/esl_stats.h $ 31 | *****************************************************************/ 32 | -------------------------------------------------------------------------------- /tools/base/FileParser.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef FILEPARSER_H_ 4 | #define FILEPARSER_H_ 5 | 6 | 7 | #include "../util/mutil.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "SVector.h" 13 | #include 14 | 15 | using namespace std; 16 | 17 | class StringParser 18 | { 19 | public: 20 | StringParser(); 21 | 22 | virtual ~StringParser(); 23 | 24 | void SetLine(const string & line); 25 | void SetLine(const string & line, const string & delimiter); 26 | 27 | int GetItemCount(); 28 | 29 | bool IsString(int index); 30 | bool IsInt(int index); 31 | bool IsFloat(int index); 32 | 33 | 34 | const string & AsString(int index); 35 | char AsChar(int index); 36 | int AsInt(int index); 37 | double AsFloat(int index); 38 | 39 | 40 | private: 41 | CMAsciiReadFileStream m_file; 42 | vector m_items; 43 | 44 | }; 45 | 46 | 47 | 48 | 49 | 50 | 51 | class FlatFileParser : public StringParser 52 | { 53 | public: 54 | FlatFileParser(); 55 | FlatFileParser(const string & fileName); 56 | 57 | virtual ~FlatFileParser(); 58 | 59 | void Open(const string & fileName); 60 | bool Exists(const string &fileName); 61 | 62 | bool ParseLine(); 63 | bool IsEndOfFile(); 64 | 65 | bool GetLine(string & line); 66 | const string & Line() const {return m_line;} 67 | 68 | void LoadVector(string &filename, vector &elements); 69 | void LoadSet(string &filename, set &elements); 70 | 71 | private: 72 | CMAsciiReadFileStream m_file; 73 | string m_line; 74 | }; 75 | 76 | 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /extern/RealFFT/test_fnc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | test_fnc.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (test_fnc_HEADER_INCLUDED) 27 | #define test_fnc_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | inline T limit (const T &x, const T &inf, const T &sup); 42 | 43 | 44 | 45 | #include "test_fnc.hpp" 46 | 47 | 48 | 49 | #endif // test_fnc_HEADER_INCLUDED 50 | 51 | 52 | 53 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 54 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/test_fnc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | test_fnc.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (test_fnc_HEADER_INCLUDED) 27 | #define test_fnc_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | inline T limit (const T &x, const T &inf, const T &sup); 42 | 43 | 44 | 45 | #include "test_fnc.hpp" 46 | 47 | 48 | 49 | #endif // test_fnc_HEADER_INCLUDED 50 | 51 | 52 | 53 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 54 | -------------------------------------------------------------------------------- /tools/visual/Color.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef COLOR_H 4 | #define COLOR_H 5 | 6 | #include 7 | using namespace std; 8 | 9 | 10 | class color { 11 | 12 | public: 13 | 14 | color( float r, float g, float b ) : r_(r), g_(g), b_(b) { } 15 | 16 | color( ) : 17 | r_(0.0), 18 | g_(0.0), 19 | b_(0.0) 20 | { } 21 | 22 | float R( ) const { return r_; } 23 | float G( ) const { return g_; } 24 | float B( ) const { return b_; } 25 | 26 | friend bool operator==( const color& lhs, const color& rhs ) 27 | { return ( lhs.r_ == rhs.r_ && lhs.g_ == rhs.g_ && lhs.b_ == rhs.b_); } 28 | 29 | friend bool operator!=( const color& lhs, const color& rhs ) 30 | { return !( lhs == rhs ); } 31 | 32 | friend std::ostream& operator<<( std::ostream& o, const color& c); 33 | 34 | private: 35 | 36 | float r_, g_, b_; 37 | }; 38 | 39 | const color white(1, 1, 1), black(0, 0, 0); 40 | const color red(1, 0, 0), green(0, 1, 0), blue(0, 0, 1); 41 | 42 | const color pink(1, 0.5, 0.5); 43 | const color lighterpink(1, 0.8, 0.8); 44 | 45 | const color magenta(1, 0, 1), yellow(1, 1, 0), cyan(0, 1, 1); 46 | 47 | const color gray(0.5, 0.5, 0.5); 48 | const color darkergray(0.3, 0.3, 0.3); 49 | const color darkgray(0.3, 0.3, 0.3); 50 | const color lightgray(0.6, 0.6, 0.6); 51 | const color lightergray(0.8, 0.8, 0.8); 52 | 53 | const color azure(0, 0.5, 1); 54 | const color orangered(1, 0.27, 0); 55 | const color seashell(1, 0.96, 0.93); 56 | const color limegreen(0.2, 0.8, 0.2); 57 | const color wheat(0.96, 0.87, 0.7); 58 | 59 | 60 | 61 | color MakeUpColor(int num); 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /analysis/DNAMatrix.h: -------------------------------------------------------------------------------- 1 | #ifndef DNAMATRIX_H 2 | #define DNAMATRIX_H 3 | 4 | #include "DNAVector.h" 5 | 6 | 7 | 8 | char DNA_Letter(double a, double c, double g, double t) 9 | { 10 | if (a > c && a > g && a > t) 11 | return 'A'; 12 | if (c > g && c > t) 13 | return 'C'; 14 | if (g > t) 15 | return 'G'; 16 | 17 | return 'T'; 18 | //return 'N'; 19 | } 20 | 21 | class DNAMatrix 22 | { 23 | public: 24 | DNAMatrix() {} 25 | 26 | void SetDNA(const DNAVector & d) { 27 | m_data.resize(d.isize()*4, 0.); 28 | 29 | int i; 30 | for (i=0; i & d) { 39 | m_vec.resize(d.isize()/4); 40 | m_data = d; 41 | int i; 42 | for (i=0; i & DataDirect() {return m_data;} 65 | const svec & Data() const {return m_data;} 66 | const DNAVector & DNA() const {return m_vec;} 67 | 68 | private: 69 | DNAVector m_vec; 70 | svec m_data; 71 | }; 72 | 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /tools/analysis/DNAMatrix.h: -------------------------------------------------------------------------------- 1 | #ifndef DNAMATRIX_H 2 | #define DNAMATRIX_H 3 | 4 | #include "analysis/DNAVector.h" 5 | 6 | 7 | 8 | char DNA_Letter(double a, double c, double g, double t) 9 | { 10 | if (a > c && a > g && a > t) 11 | return 'A'; 12 | if (c > g && c > t) 13 | return 'C'; 14 | if (g > t) 15 | return 'G'; 16 | 17 | return 'T'; 18 | //return 'N'; 19 | } 20 | 21 | class DNAMatrix 22 | { 23 | public: 24 | DNAMatrix() {} 25 | 26 | void SetDNA(const DNAVector & d) { 27 | m_data.resize(d.isize()*4, 0.); 28 | 29 | int i; 30 | for (i=0; i & d) { 39 | m_vec.resize(d.isize()/4); 40 | m_data = d; 41 | int i; 42 | for (i=0; i & DataDirect() {return m_data;} 65 | const svec & Data() const {return m_data;} 66 | const DNAVector & DNA() const {return m_vec;} 67 | 68 | private: 69 | DNAVector m_vec; 70 | svec m_data; 71 | }; 72 | 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /tools/src/Cola/NOIAligner.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include "src/Cola/NOIAligner.h" 6 | 7 | #define MIN_ALIGN_LEN 5 8 | 9 | //===================================================================== 10 | 11 | const AlignmentSet& NOIAligner::align() { 12 | recurseAlign(0, targetSeq.isize(), 0, querySeq.isize()); 13 | return alignments; 14 | } 15 | 16 | void NOIAligner::recurseAlign(int targetStart, int targetStop, int queryStart, int queryStop) { 17 | DNAVector t,q; 18 | t.SetToSubOf(targetSeq, targetStart, targetStop-targetStart); 19 | q.SetToSubOf(querySeq, queryStart, queryStop-queryStart); 20 | Cola cola1 = Cola(); 21 | AlignmentCola algn = cola1.createAlignment(t, q, aligner); 22 | // No significant alignment was found in region hence no recursion needed 23 | // TODO parameterise 24 | if(algn.calcPVal()>0.1) { return; } 25 | 26 | alignments.add(algn); 27 | 28 | // The part before the current alignment starts from target/queryStart upto target/queryStop1 29 | int targetStop1 = algn.getTargetOffset(); 30 | int queryStop1 = algn.getQueryOffset(); 31 | if((targetStop1-targetStart>MIN_ALIGN_LEN) && (queryStop1-queryStart>MIN_ALIGN_LEN)) { 32 | recurseAlign(targetStart, targetStop1, queryStart, queryStop1); 33 | } 34 | // The part after the current alignment starts from target/queryStart2 upto target/queryStop 35 | int targetStart2 = targetStart + algn.getTargetOffset() + algn.getTargetBaseAligned(); 36 | int queryStart2 = queryStart + algn.getQueryOffset() + algn.getQueryBaseAligned(); 37 | if((targetStop-targetStart2>MIN_ALIGN_LEN) && (queryStop-queryStart2>MIN_ALIGN_LEN)) { 38 | recurseAlign(targetStart2, targetStop, queryStart2, queryStop); 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /extern/RealFFT/test_fnc.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | test_fnc.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (test_fnc_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of test_fnc code header. 28 | #endif 29 | #define test_fnc_CURRENT_CODEHEADER 30 | 31 | #if ! defined (test_fnc_CODEHEADER_INCLUDED) 32 | #define test_fnc_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | T limit (const T &x, const T &inf, const T &sup) 42 | { 43 | assert (! (sup < inf)); 44 | 45 | return ((x < inf) ? inf : ((sup < x) ? sup : x)); 46 | } 47 | 48 | 49 | 50 | #endif // test_fnc_CODEHEADER_INCLUDED 51 | 52 | #undef test_fnc_CURRENT_CODEHEADER 53 | 54 | 55 | 56 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 57 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/test_fnc.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | test_fnc.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (test_fnc_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of test_fnc code header. 28 | #endif 29 | #define test_fnc_CURRENT_CODEHEADER 30 | 31 | #if ! defined (test_fnc_CODEHEADER_INCLUDED) 32 | #define test_fnc_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | T limit (const T &x, const T &inf, const T &sup) 42 | { 43 | assert (! (sup < inf)); 44 | 45 | return ((x < inf) ? inf : ((sup < x) ? sup : x)); 46 | } 47 | 48 | 49 | 50 | #endif // test_fnc_CODEHEADER_INCLUDED 51 | 52 | #undef test_fnc_CURRENT_CODEHEADER 53 | 54 | 55 | 56 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 57 | -------------------------------------------------------------------------------- /extern/RealFFT/def.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | def.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | //BI: added define here 25 | #define NDEBUG 26 | 27 | #if ! defined (def_HEADER_INCLUDED) 28 | #define def_HEADER_INCLUDED 29 | 30 | #if defined (_MSC_VER) 31 | #pragma once 32 | #pragma warning (4 : 4250) // "Inherits via dominance." 33 | #endif 34 | 35 | 36 | 37 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 38 | 39 | 40 | 41 | 42 | const double PI = 3.1415926535897932384626433832795; 43 | const double SQRT2 = 1.41421356237309514547462185873883; 44 | 45 | #if defined (_MSC_VER) 46 | 47 | #define FORCEINLINE __forceinline 48 | 49 | #else 50 | 51 | #define FORCEINLINE inline 52 | 53 | #endif 54 | 55 | 56 | 57 | #endif // def_HEADER_INCLUDED 58 | 59 | 60 | 61 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 62 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/def.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | def.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | //BI: added define here 25 | #define NDEBUG 26 | 27 | #if ! defined (def_HEADER_INCLUDED) 28 | #define def_HEADER_INCLUDED 29 | 30 | #if defined (_MSC_VER) 31 | #pragma once 32 | #pragma warning (4 : 4250) // "Inherits via dominance." 33 | #endif 34 | 35 | 36 | 37 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 38 | 39 | 40 | 41 | 42 | const double PI = 3.1415926535897932384626433832795; 43 | const double SQRT2 = 1.41421356237309514547462185873883; 44 | 45 | #if defined (_MSC_VER) 46 | 47 | #define FORCEINLINE __forceinline 48 | 49 | #else 50 | 51 | #define FORCEINLINE inline 52 | 53 | #endif 54 | 55 | 56 | 57 | #endif // def_HEADER_INCLUDED 58 | 59 | 60 | 61 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 62 | -------------------------------------------------------------------------------- /extern/RealFFT/FFTRealSelect.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealSelect.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (FFTRealSelect_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of FFTRealSelect code header. 28 | #endif 29 | #define FFTRealSelect_CURRENT_CODEHEADER 30 | 31 | #if ! defined (FFTRealSelect_CODEHEADER_INCLUDED) 32 | #define FFTRealSelect_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | float * FFTRealSelect

::sel_bin (float *e_ptr, float *o_ptr) 42 | { 43 | return (o_ptr); 44 | } 45 | 46 | 47 | 48 | template <> 49 | float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr) 50 | { 51 | return (e_ptr); 52 | } 53 | 54 | 55 | 56 | #endif // FFTRealSelect_CODEHEADER_INCLUDED 57 | 58 | #undef FFTRealSelect_CURRENT_CODEHEADER 59 | 60 | 61 | 62 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 63 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/FFTRealSelect.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealSelect.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (FFTRealSelect_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of FFTRealSelect code header. 28 | #endif 29 | #define FFTRealSelect_CURRENT_CODEHEADER 30 | 31 | #if ! defined (FFTRealSelect_CODEHEADER_INCLUDED) 32 | #define FFTRealSelect_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | float * FFTRealSelect

::sel_bin (float *e_ptr, float *o_ptr) 42 | { 43 | return (o_ptr); 44 | } 45 | 46 | 47 | 48 | template <> 49 | float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr) 50 | { 51 | return (e_ptr); 52 | } 53 | 54 | 55 | 56 | #endif // FFTRealSelect_CODEHEADER_INCLUDED 57 | 58 | #undef FFTRealSelect_CURRENT_CODEHEADER 59 | 60 | 61 | 62 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 63 | -------------------------------------------------------------------------------- /tools/src/Cola/EditGraph.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include "EditGraph.h" 6 | 7 | //===================================================================== 8 | void EditGraphNode::setCPACords(EditGraphNode* parent, int midCol) { 9 | if(col == midCol) { 10 | CPArow = row; 11 | CPAdepth = depth; 12 | } else if(col > midCol) { 13 | CPArow = parent->getCPARow(); 14 | CPAdepth = parent->getCPADepth(); 15 | } 16 | } 17 | 18 | //===================================================================== 19 | void EditGraphDepth::init(int row, int col) { 20 | for( int depth=0; depth3 && currNode->getScore()==MINUS_INF) { break; } 24 | else { currNode->setScore(MINUS_INF); } 25 | } 26 | } 27 | 28 | 29 | //===================================================================== 30 | void EditGraph::initCol(int col, int startRow, int endRow) { 31 | // Only need to reset nodes that fall within the bandwidth boundaries for banded alignment 32 | int start = max(startRow-1, col-bandWidth-1); 33 | int end = min(endRow, col+bandWidth+1); 34 | for(int row=start; row<=end; row++) { 35 | getCell(row, col)->setBestNode(0); //Reset the bestNode index 36 | getCell(row, col)->init(row, col); 37 | } 38 | } 39 | 40 | void EditGraph::updateBest(EditGraphNode* bNode) { 41 | if(!bNode) { 42 | bestScoredNode.setScore(MINUS_INF); 43 | } else if( bNode->getScore() > bestScoredNode.getScore()) { 44 | bestScoredNode = *bNode; 45 | } 46 | } 47 | 48 | void EditGraph::checkPoint(int col, int maxStartRow, int minEndRow) { 49 | // Only need to save nodes that fall within the bandwidth boundaries for banded alignment 50 | EditGraphColumn* colDat = getColumn(col); 51 | for(int row=maxStartRow; row<=minEndRow; row++) { 52 | checkpointCol.setCell(row, colDat->getCell(row)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tools/src/Cola/SWGAaligner.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include "SWGAaligner.h" 6 | 7 | void SWGAaligner::visitNode(EditGraphNode* currNode, int currCheckpointColIndex) { 8 | int i = currNode->getRow(); 9 | int j = currNode->getCol(); 10 | int k = currNode->getDepth(); 11 | double s, score1, score2; 12 | switch(k) { 13 | case 0: //Moving vertically 14 | score1 = editGraph.getNode(i-1, j, k)->getScore() + params.getGapExtP(); 15 | score2 = editGraph.getBestScoreAtRowCol(i-1, j) + params.getGapOpenP(); 16 | if(score1>score2) { 17 | currNode->setScore(score1); 18 | currNode->setCPACords(editGraph.getNode(i-1, j, k), 19 | currCheckpointColIndex); 20 | } else { 21 | currNode->setScore(score2); 22 | currNode->setCPACords(editGraph.getBestNodeAtRowCol(i-1, j), 23 | currCheckpointColIndex); 24 | } 25 | break; 26 | case 1: //Moving horizontally 27 | score1 = editGraph.getNode(i, j-1, k)->getScore() + params.getGapExtP(); 28 | score2 = editGraph.getBestScoreAtRowCol(i, j-1) + params.getGapOpenP(); 29 | if(score1>score2) { 30 | currNode->setScore(score1); 31 | currNode->setCPACords(editGraph.getNode(i, j-1, k), 32 | currCheckpointColIndex); 33 | } else { 34 | currNode->setScore(score2); 35 | currNode->setCPACords(editGraph.getBestNodeAtRowCol(i, j-1), 36 | currCheckpointColIndex); 37 | } 38 | break; 39 | case 2: //Moving diagonally 40 | s = editGraph.getBestScoreAtRowCol(i-1,j-1); 41 | if( getTargetSeq()[j] == getQuerySeq()[i] ) { 42 | // The scoring is uniform for SW as opposed to NS 43 | if(i*j==0 && s==MINUS_INF) { s = 0; } // special case for first row/column 44 | currNode->setScore(s + 1); 45 | } else { 46 | currNode->setScore(s + params.getMismatchP()); 47 | } 48 | currNode->setCPACords(editGraph.getBestNodeAtRowCol(i-1, j-1), 49 | currCheckpointColIndex); 50 | break; 51 | default: 52 | currNode->setScore(MINUS_INF); 53 | } 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /tools/src/Cola/NSGAaligner.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include "NSGAaligner.h" 6 | 7 | void NSGAaligner::visitNode(EditGraphNode* currNode, int currCheckpointColIndex) { 8 | if (currNode->getDepth() < 2) { // Can reuse affine zero-contiguity function 9 | SWGAaligner::visitNode(currNode, currCheckpointColIndex); 10 | } else { 11 | visitNodeCola(currNode, currCheckpointColIndex); 12 | } 13 | } 14 | 15 | void NSGAaligner::visitNodeCola(EditGraphNode* currNode, int currCheckpointColIndex) { 16 | // Choose the best vertical, horizontal (k=0,1) and diagonal move with zero depth of contig 17 | int i = currNode->getRow(); 18 | int j = currNode->getCol(); 19 | int k = currNode->getDepth(); 20 | if(k==2) { 21 | double score1, score2 = MINUS_INF; 22 | score1 = editGraph.getBestScoreAtRowCol(i, j); 23 | // Moving from the diagonal neighbour 24 | score2 = editGraph.getBestScoreAtRowCol(i-1, j-1) + params.getMismatchP(); 25 | if ( score2 >= score1 ) { 26 | currNode->setScore(score2); 27 | currNode->setCPACords(editGraph.getBestNodeAtRowCol(i-1, j-1), 28 | currCheckpointColIndex); 29 | } else { 30 | currNode->setScore(score1); 31 | // Pass in -1 for currCheckpoint Col to ensure that the parent nodes CPA gets set 32 | currNode->setCPACords(editGraph.getBestNodeAtRowCol(i,j), -1); 33 | } 34 | } else { 35 | // Moving from the diagonal neighbour only if there's a match. 36 | if( getTargetSeq()[j] == getQuerySeq()[i] ) { 37 | double s = editGraph.getNode(i-1,j-1,k-1)->getScore(); 38 | if(i*j==0 && k==3 && s==MINUS_INF) { s = 0; } // special case for first row/column 39 | if (s != MINUS_INF) { 40 | int depth = k - 2; 41 | currNode->setScore(s - pow(((depth-1)-0)/1.0, 3) + pow((depth-0)/1.0, 3)); 42 | // currNode->setScore(s - pow(1.9,((depth-1)-0)/1) + pow(1.9,(depth-0)/1)); 43 | // currNode->setScore(s + depth); 44 | currNode->setCPACords(editGraph.getNode(i-1, j-1, k-1), currCheckpointColIndex); 45 | } 46 | } else { 47 | currNode->setScore(MINUS_INF);// There is no match: 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tools/analysis/SatsumaAlign.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SATSUMAALIGN_H_ 3 | #define _SATSUMAALIGN_H_ 4 | 5 | #include "base/SVector.h" 6 | 7 | #include 8 | 9 | class SAlign 10 | { 11 | public: 12 | SAlign() { 13 | m_startTarget = -1; 14 | m_endTarget = -1; 15 | m_startQuery = -1; 16 | m_endQuery = -1; 17 | m_direction = 0; 18 | m_ident = 0.; 19 | } 20 | 21 | 22 | void Set(const string & t, 23 | const string & q, 24 | int startTarget, 25 | int endTarget, 26 | int startQuery, 27 | int endQuery, 28 | double ident, 29 | const string & dir) { 30 | 31 | m_target = t; 32 | m_query = q; 33 | m_startTarget = startTarget; 34 | m_endTarget = endTarget; 35 | m_startQuery = startQuery; 36 | m_endQuery = endQuery; 37 | m_ident = ident; 38 | if (dir == "+" || dir == "1") 39 | m_direction = 1; 40 | if (dir == "-" || dir == "-1") 41 | m_direction = -1; 42 | 43 | } 44 | 45 | 46 | const string & Query() const {return m_query;} 47 | const string & Target() const {return m_target;} 48 | int StartTarget() const {return m_startTarget;} 49 | int EndTarget() const {return m_endTarget;} 50 | int StartQuery() const {return m_startQuery;} 51 | int EndQuery() const {return m_endQuery;} 52 | int Direction() const {return m_direction;} 53 | double Identity() const {return m_ident;} 54 | 55 | 56 | private: 57 | string m_query; 58 | string m_target; 59 | int m_startTarget; 60 | int m_endTarget; 61 | int m_startQuery; 62 | int m_endQuery; 63 | int m_direction; 64 | double m_ident; 65 | 66 | }; 67 | 68 | 69 | 70 | 71 | class SAlignVec 72 | { 73 | public: 74 | SAlignVec() { 75 | m_count = 0; 76 | } 77 | 78 | void Read(const string & fileName); 79 | void Write(const string & fileName); 80 | 81 | SAlign & operator[] (int i) {return m_aligns[i];} 82 | const SAlign & operator[] (int i) const {return m_aligns[i];} 83 | 84 | int isize() const {return m_count;} 85 | 86 | void clear() { 87 | m_count = 0; 88 | m_aligns.clear(); 89 | } 90 | 91 | private: 92 | int m_count; 93 | svec m_aligns; 94 | }; 95 | 96 | 97 | #endif //_SATSUMAALIGN_H_ 98 | 99 | -------------------------------------------------------------------------------- /tools/analysis/Coordinate.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include "analysis/Coordinate.h" 6 | 7 | 8 | 9 | //====================================================== 10 | void Coordinate::set(const string& ch, bool ori, 11 | int str, int stp) { 12 | setChr(ch); 13 | setOrient(ori); 14 | setStart(str); 15 | setStop(stp); 16 | } 17 | 18 | void Coordinate::set(const string& ch, char ori, 19 | int str, int stp) { 20 | setChr(ch); 21 | setOrient(ori); 22 | setStart(str); 23 | setStop(stp); 24 | } 25 | 26 | bool Coordinate::contains(const Coordinate& other) const { 27 | return( (other.getChr() == getChr()) 28 | && ( (other.getStart()>=getStart())&& (other.getStop()<=getStop()) 29 | ) 30 | ); 31 | } 32 | 33 | bool Coordinate::isSameCoords(const Coordinate& other) const { 34 | return( (other.getChr() == getChr()) 35 | && ( (other.getStart()==getStart())&& (other.getStop()==getStop()) 36 | ) 37 | ); 38 | } 39 | 40 | bool Coordinate::hasOverlap(const Coordinate& other) const { 41 | //For any overlap either the start or stop of one of the coords has to lie within the other coord 42 | return( (other.getChr() == getChr()) 43 | && !( (other.getStart()>getStop())|| (other.getStop() 42 | class FFTRealSelect 43 | { 44 | 45 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 46 | 47 | public: 48 | 49 | FORCEINLINE static float * 50 | sel_bin (float *e_ptr, float *o_ptr); 51 | 52 | 53 | 54 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 55 | 56 | private: 57 | 58 | FFTRealSelect (); 59 | ~FFTRealSelect (); 60 | FFTRealSelect (const FFTRealSelect &other); 61 | FFTRealSelect& operator = (const FFTRealSelect &other); 62 | bool operator == (const FFTRealSelect &other); 63 | bool operator != (const FFTRealSelect &other); 64 | 65 | }; // class FFTRealSelect 66 | 67 | 68 | 69 | #include "extern/RealFFT/FFTRealSelect.hpp" 70 | 71 | 72 | 73 | #endif // FFTRealSelect_HEADER_INCLUDED 74 | 75 | 76 | 77 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/FFTRealSelect.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealSelect.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (FFTRealSelect_HEADER_INCLUDED) 27 | #define FFTRealSelect_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #endif 32 | 33 | 34 | 35 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 36 | 37 | #include "extern/RealFFT/def.h" 38 | 39 | 40 | 41 | template 42 | class FFTRealSelect 43 | { 44 | 45 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 46 | 47 | public: 48 | 49 | FORCEINLINE static float * 50 | sel_bin (float *e_ptr, float *o_ptr); 51 | 52 | 53 | 54 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 55 | 56 | private: 57 | 58 | FFTRealSelect (); 59 | ~FFTRealSelect (); 60 | FFTRealSelect (const FFTRealSelect &other); 61 | FFTRealSelect& operator = (const FFTRealSelect &other); 62 | bool operator == (const FFTRealSelect &other); 63 | bool operator != (const FFTRealSelect &other); 64 | 65 | }; // class FFTRealSelect 66 | 67 | 68 | 69 | #include "extern/RealFFT/FFTRealSelect.hpp" 70 | 71 | 72 | 73 | #endif // FFTRealSelect_HEADER_INCLUDED 74 | 75 | 76 | 77 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | -------------------------------------------------------------------------------- /tools/analysis/Blosum.h: -------------------------------------------------------------------------------- 1 | #ifndef BLOSUM_H 2 | #define BLOSUM_H 3 | 4 | #include "DNAVector.h" 5 | 6 | const int blosum_table[] = 7 | { 8 | 4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2, -1, 9 | -4, 0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2, 10 | -3, -4, -2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, 11 | -3, 1, -4, -1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, 12 | -3, -2, 4, -4, -2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, 13 | -1, 1, 3, -3, -4, 0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, 14 | -2, -3, -2, -3, -2, -4, -2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, 15 | -1, -2, -3, -2, 2, 0, -4, -1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, 16 | -3, -2, -1, 3, -3, -1, -3, -4, -1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 17 | 1, 2, 0, -1, -2, -3, -2, 1, -4, -1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, 18 | -3, -2, -2, -2, -1, 1, -2, -1, -3, -4, -1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, 19 | -2, -2, 0, -1, -1, -1, 1, -1, -1, -1, -4, -2, -3, 1, 0, -3, 0, 1, -3, 0, -3, 20 | -2, 6, -2, 0, 0, 1, 0, -3, -4, -2, 0, -4, -1, -3, -1, -1, -4, -2, -2, -3, -1, 21 | -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3, -1, -4, -1, -3, 0, 2, -3, -2, 0, -3, 22 | 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1, 3, -4, -1, -3, -2, 0, -3, -2, 0, 23 | -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2, 0, -4, 1, -1, 0, 0, -2, 0, 24 | -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2, 0, -4, 0, -1, -1, -1, -2, 25 | -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2, -1, -4, 0, -1, -3, -2, 26 | -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1, -2, -4, -3, -2, -4, 27 | -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2, -3, -4, -2, -2, 28 | -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7, -2, -4, -1, 29 | -3, 1, 4, -3, -2, 0, -3, 1, -3, -1, 0, -1, 3, 0, 0, -1, -2, -3, -2, 4, -4, 30 | -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 31 | 1, 32 | }; 33 | 34 | inline int Similarity(char a, char b) 35 | { 36 | int i1 = AminoAcidIndex(a); 37 | int i2 = AminoAcidIndex(b); 38 | 39 | if (i1 < 0 || i2 < 0) 40 | return -100; 41 | 42 | return blosum_table[22*i1+i2]; 43 | } 44 | 45 | 46 | #endif 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /tools/util/FindProcess.cc: -------------------------------------------------------------------------------- 1 | #include "base/FileParser.h" 2 | 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "util/FindProcess.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | /* 17 | int 18 | readlink (const char *path, char *buf, size_t bufsize) 19 | { 20 | struct stat statbuf; 21 | 22 | if (stat (path, &statbuf) >= 0) 23 | errno = EINVAL; 24 | return -1; 25 | }*/ 26 | 27 | int getProcessCount(const string & p_processname) { 28 | #ifdef __APPLE_CC__ 29 | printf("You are running MAC OS, checking for running applications is NOT supported.\n"); 30 | return 0; 31 | #endif 32 | 33 | 34 | DIR *dir_p; 35 | struct dirent *dir_entry_p; 36 | char dir_name[40]; // ??? buffer overrun potential 37 | char target_name[252]; // ??? buffer overrun potential 38 | int target_result; 39 | char exe_link[252]; 40 | int errorcount; 41 | int result = 0xFFFFFFFF; 42 | 43 | errorcount=0; 44 | result=0; 45 | dir_p = opendir("/proc/"); // Open /proc/ directory 46 | 47 | int count = 0; 48 | 49 | while(NULL != (dir_entry_p = readdir(dir_p))) { // Reading /proc/ entries 50 | if (strspn(dir_entry_p->d_name, "0123456789") == strlen(dir_entry_p->d_name)) { // Checking for numbered directories 51 | strcpy(dir_name, "/proc/"); 52 | strcat(dir_name, dir_entry_p->d_name); 53 | strcat(dir_name, "/"); // Obtaining the full-path eg: /proc/24657/ 54 | exe_link[0] = 0; 55 | strcat(exe_link, dir_name); 56 | strcat(exe_link, "exe"); // Getting 57 | 58 | //printf("Checking %s\n", dir_name); 59 | strcat(dir_name, "status"); 60 | 61 | FILE * pStat = fopen(dir_name, "r"); 62 | if (pStat == NULL) 63 | continue; 64 | fclose(pStat); 65 | 66 | 67 | FlatFileParser parser; 68 | 69 | try { 70 | parser.Open(dir_name); 71 | } 72 | catch(...) { 73 | continue; 74 | } 75 | while (parser.ParseLine()) { 76 | if (parser.AsString(0) == "Name:") { 77 | if (parser.AsString(1) == p_processname) 78 | count++; 79 | } 80 | } 81 | 82 | } 83 | } 84 | closedir(dir_p); 85 | 86 | return count; 87 | } 88 | 89 | -------------------------------------------------------------------------------- /tools/src/Cola/findColaSigDist.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "extern/easel/esl_gumbel.h" 5 | 6 | #include "base/CommandLineParser.h" 7 | #include "src/Cola/Cola.h" 8 | 9 | int main(int argc,char** argv) 10 | { 11 | commandArg alignerTypeCmd("-a","Aligner type - Choose 1 : NSGA , 2 : NS , 3 : SWGA, 4 : SW "); 12 | commandArg gapOpenCmd("-o", "Aligner gap open penalty"); 13 | commandArg mismatchCmd("-m", "Aligner Mismatch penalty"); 14 | commandArg gapExtCmd("-e", "Aligner gap extension penalty"); 15 | 16 | commandLineParser P(argc,argv); 17 | P.SetDescription("Estimate EVD parameters for the given cola aligner/parameters"); 18 | P.registerArg(alignerTypeCmd); 19 | P.registerArg(gapOpenCmd); 20 | P.registerArg(mismatchCmd); 21 | P.registerArg(gapExtCmd); 22 | 23 | P.parse(); 24 | 25 | AlignerType aType = AlignerType(P.GetIntValueFor(alignerTypeCmd)); 26 | int gapOpenPen = P.GetIntValueFor(gapOpenCmd); 27 | int mismatchPen = P.GetIntValueFor(mismatchCmd); 28 | int gapExtPen = P.GetIntValueFor(gapExtCmd); 29 | 30 | vecDNAVector query, target; 31 | 32 | string file1 = "data/FDRTestFW1000.fasta"; 33 | string file2 = "data/FDRTestRC1000.fasta"; 34 | query.Read(file1); 35 | target.Read(file2); 36 | query.RemoveGaps(); 37 | target.RemoveGaps(); 38 | double* samples = new double[100000]; 39 | int numOfSamples = 0; 40 | int i, j; 41 | srand((unsigned)time(0)); 42 | Cola cola1 = Cola(); 43 | for (i=0; i 4 | #include 5 | #include 6 | #include 7 | #include 8 | #define __STDC_LIMIT_MACROS 9 | #include 10 | #include 11 | #include "matchresult.h" 12 | 13 | #define KMATCH_MAX_FREQ 4 14 | #define KMATCH_NUC_A 0 15 | #define KMATCH_NUC_C 1 16 | #define KMATCH_NUC_G 2 17 | #define KMATCH_NUC_T 3 18 | #define KMATCH_NOKMER INT64_MIN 19 | #define KMATCH_POSITION_CHR_CNST 10000000000L 20 | 21 | typedef struct kmer_position_s { 22 | uint64_t kmer; //canonical kmer 23 | int64_t position; //sign indicates direction +FW -REV 24 | bool operator <(const kmer_position_s& rhs) const{ 25 | return (kmer < rhs.kmer); 26 | } 27 | 28 | } kmer_position_t; 29 | 30 | typedef struct kmer_match_s { 31 | int64_t q_position; 32 | int64_t t_position; 33 | bool reverse; 34 | bool operator <(const kmer_match_s& rhs) const{ 35 | return (q_position < rhs.q_position); 36 | } 37 | } kmer_match_t; // if a kmer is High Frequency, then a (pos, -1) and a (-1, pos) are added. TODO: allow for HF in only one. 38 | 39 | typedef struct multikmer_match_s { 40 | int64_t q_start; 41 | int64_t t_start; 42 | bool reverse; 43 | int64_t length; 44 | } multikmer_match_t; 45 | 46 | typedef struct { 47 | std::string name; 48 | uint64_t length; 49 | } seq_attributes_t; 50 | 51 | inline int64_t str_to_kmer(const char * _str); //returns a canonical kmer with sign indicating position, KMATCH_NOKMER if invalid input 52 | 53 | class KMatch { 54 | public: 55 | KMatch(char * _target_filename, char * _query_filename, uint8_t _K, int _max_freq); 56 | void load_query_positions(); 57 | void load_target_positions(); 58 | void merge_positions(); 59 | void clear_positions(); 60 | void dump_matching_blocks(char * out_filename, int min_length, int max_gap); 61 | private: 62 | uint8_t K; 63 | char * target_filename; 64 | char * query_filename; 65 | int max_freq; 66 | void kmer_array_from_fasta(char * filename, std::vector & kposv, std::vector & seqnames); 67 | 68 | std::vector target_seqs, query_seqs; 69 | std::vector target_positions, query_positions; 70 | std::vector kmatches; 71 | }; 72 | 73 | #endif //KMATCH_INCLUDED 74 | -------------------------------------------------------------------------------- /tools/analysis/SatsumaToFasta.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../base/CommandLineParser.h" 3 | #include "../base/FileParser.h" 4 | #include "DNAVector.h" 5 | 6 | 7 | void Print(const string &s) { 8 | int n = strlen(s.c_str()); 9 | for (int i=0; i fileCmmd("-i","satsuma file"); 20 | commandArg fastaCmmd("-f","fasta file to get sequence from"); 21 | commandArg tCmmd("-t","output target sequence", false); 22 | commandArg slackCmmd("-s","flanks on each side", 0); 23 | commandLineParser P(argc,argv); 24 | P.SetDescription("Generates a FASTA file from a satsuma summary file."); 25 | P.registerArg(fileCmmd); 26 | P.registerArg(tCmmd); 27 | P.registerArg(fastaCmmd); 28 | P.registerArg(slackCmmd); 29 | 30 | P.parse(); 31 | 32 | string fileName = P.GetStringValueFor(fileCmmd); 33 | string fastaName = P.GetStringValueFor(fastaCmmd); 34 | bool bTarget = P.GetBoolValueFor(tCmmd); 35 | int slack = P.GetIntValueFor(slackCmmd); 36 | 37 | vecDNAVector dna; 38 | dna.Read(fastaName); 39 | 40 | //comment. ??? 41 | FlatFileParser parser; 42 | 43 | parser.Open(fileName); 44 | while (parser.ParseLine()) { 45 | if (parser.GetItemCount() == 0) 46 | continue; 47 | string chr; 48 | int start = 0; 49 | int stop = 0; 50 | bool bRC = false; 51 | if (bTarget) { 52 | chr = parser.AsString(0); 53 | start = parser.AsInt(1); 54 | stop = parser.AsInt(2); 55 | } else { 56 | chr = parser.AsString(3); 57 | start = parser.AsInt(4); 58 | stop = parser.AsInt(5); 59 | if (parser.AsString(7) == "-") 60 | bRC = true; 61 | } 62 | const DNAVector & d = dna(chr); 63 | start -= slack; 64 | if (start < 0) 65 | start = 0; 66 | stop += slack; 67 | if (stop >= d.isize()) 68 | stop = d.isize(); 69 | 70 | cout << ">" << chr << ":" << start << "-" << stop << endl; 71 | int k = 0; 72 | 73 | DNAVector small; 74 | small.SetToSubOf(d, start, stop-start); 75 | if (bRC) 76 | small.ReverseComplement(); 77 | for (int i=0; i 0 && k % 80 == 0) 80 | cout << endl; 81 | k++; 82 | } 83 | cout << endl; 84 | } 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /tools/extern/easel/esl_gumbel.h: -------------------------------------------------------------------------------- 1 | /* esl_gumbel.h 2 | * Gumbel (type I extreme value) distributions. 3 | * 4 | * SRE, Mon Jun 27 08:44:41 2005 [St. Louis] 5 | * SVN $Id: esl_gumbel.h 664 2011-02-27 17:08:36Z eddys $ 6 | * SVN $URL: https://svn.janelia.org/eddylab/eddys/easel/trunk/esl_gumbel.h $ 7 | */ 8 | #ifndef eslGUMBEL_INCLUDED 9 | #define eslGUMBEL_INCLUDED 10 | 11 | #ifdef eslAUGMENT_RANDOM 12 | #include 13 | #endif 14 | 15 | extern double esl_gumbel_pdf (double x, double mu, double lambda); 16 | extern double esl_gumbel_logpdf (double x, double mu, double lambda); 17 | extern double esl_gumbel_cdf (double x, double mu, double lambda); 18 | extern double esl_gumbel_logcdf (double x, double mu, double lambda); 19 | extern double esl_gumbel_surv (double x, double mu, double lambda); 20 | extern double esl_gumbel_logsurv(double x, double mu, double lambda); 21 | extern double esl_gumbel_invcdf (double p, double mu, double lambda); 22 | extern double esl_gumbel_invsurv(double p, double mu, double lambda); 23 | 24 | 25 | extern double esl_gumbel_generic_pdf (double x, void *params); 26 | extern double esl_gumbel_generic_cdf (double x, void *params); 27 | extern double esl_gumbel_generic_surv (double x, void *params); 28 | extern double esl_gumbel_generic_invcdf(double p, void *params); 29 | 30 | extern int esl_gumbel_Plot(FILE *fp, double mu, double lambda, 31 | double (*func)(double x, double mu, double lambda), 32 | double xmin, double xmax, double xstep); 33 | 34 | #ifdef eslAUGMENT_RANDOM 35 | extern double esl_gumbel_Sample(ESL_RANDOMNESS *r, double mu, double lambda); 36 | #endif 37 | 38 | extern int esl_gumbel_FitComplete(double *x, int n, 39 | double *ret_mu, double *ret_lambda); 40 | extern int esl_gumbel_FitCompleteLoc(double *x, int n, double lambda, 41 | double *ret_mu); 42 | extern int esl_gumbel_FitCensored(double *x, int n, int z, double phi, 43 | double *ret_mu, double *ret_lambda); 44 | extern int esl_gumbel_FitCensoredLoc(double *x, int n, int z, double phi, 45 | double lambda, double *ret_mu); 46 | #ifdef eslAUGMENT_MINIMIZER 47 | extern int esl_gumbel_FitTruncated(double *x, int n, double phi, 48 | double *ret_mu, double *ret_lambda); 49 | #endif 50 | 51 | 52 | #endif /*eslGUMBEL_INCLUDED*/ 53 | /***************************************************************** 54 | * @LICENSE@ 55 | *****************************************************************/ 56 | -------------------------------------------------------------------------------- /analysis/ChainMatches.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | 6 | 7 | #include 8 | 9 | #include "../base/CommandLineParser.h" 10 | #include "MatchDynProg.h" 11 | #include "SequenceMatch.h" 12 | 13 | //================================================================ 14 | //================================================================ 15 | //================================================================ 16 | //================================================================ 17 | int main( int argc, char** argv ) 18 | { 19 | //commandArg aStringCmmd("-q","query fasta sequence"); 20 | //commandArg bStringCmmd("-t","target fasta sequence"); 21 | commandArg iStringCmmd("-i","XCorr input file (binary)"); 22 | commandArg oStringCmmd("-o","output file (binary)"); 23 | commandArg mLenCmmd("-min_len","minimum length to force keep", 220); 24 | commandArg mIdCmmd("-min_id","minimum identity to force keep", 0.57); 25 | commandArg dupCmmd("-dups","allow for duplications", false); 26 | 27 | 28 | commandLineParser P(argc,argv); 29 | P.SetDescription("Chains matches found by HomologyByXCorr via dynamic programming"); 30 | //P.registerArg(aStringCmmd); 31 | //P.registerArg(bStringCmmd); 32 | P.registerArg(oStringCmmd); 33 | P.registerArg(iStringCmmd); 34 | P.registerArg(mLenCmmd); 35 | P.registerArg(mIdCmmd); 36 | P.registerArg(dupCmmd); 37 | //P.registerArg(lQoffCmmd); 38 | //P.registerArg(lToffCmmd); 39 | 40 | P.parse(); 41 | 42 | // String sQuery = P.GetStringValueFor(aStringCmmd); 43 | //String sTarget = P.GetStringValueFor(bStringCmmd); 44 | string input = P.GetStringValueFor(iStringCmmd); 45 | string output = P.GetStringValueFor(oStringCmmd); 46 | 47 | int minLenForce = P.GetIntValueFor(mLenCmmd); 48 | double minIdentForce = P.GetDoubleValueFor(mIdCmmd); 49 | bool bDup = P.GetBoolValueFor(dupCmmd); 50 | 51 | //int t_offset = P.GetIntValueFor(lToffCmmd); 52 | //int q_offset = P.GetIntValueFor(lQoffCmmd); 53 | 54 | 55 | 56 | int i, j, k; 57 | 58 | MultiMatches in, out; 59 | 60 | in.Read(input); 61 | cout << "Done loading." << endl; 62 | 63 | cout << "Total matches: " << in.GetMatchCount() << endl; 64 | 65 | in.Sort(); 66 | in.Collapse(); 67 | 68 | if (bDup) 69 | RunMatchDynProgMult(out, in); 70 | else 71 | RunMatchDynProg(out, in); 72 | 73 | //out.Collapse(); 74 | cout << "Saving result..." << endl; 75 | out.Write(output); 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /tools/analysis/ChainMatches.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | 6 | 7 | #include 8 | 9 | #include "base/CommandLineParser.h" 10 | #include "analysis/MatchDynProg.h" 11 | #include "analysis/SequenceMatch.h" 12 | 13 | //================================================================ 14 | //================================================================ 15 | //================================================================ 16 | //================================================================ 17 | int main( int argc, char** argv ) 18 | { 19 | //commandArg aStringCmmd("-q","query fasta sequence"); 20 | //commandArg bStringCmmd("-t","target fasta sequence"); 21 | commandArg iStringCmmd("-i","XCorr input file (binary)"); 22 | commandArg oStringCmmd("-o","output file (binary)"); 23 | commandArg mLenCmmd("-min_len","minimum length to force keep", 220); 24 | commandArg mIdCmmd("-min_id","minimum identity to force keep", 0.57); 25 | commandArg dupCmmd("-dups","allow for duplications", false); 26 | 27 | 28 | commandLineParser P(argc,argv); 29 | P.SetDescription("Chains matches found by HomologyByXCorr via dynamic programming"); 30 | //P.registerArg(aStringCmmd); 31 | //P.registerArg(bStringCmmd); 32 | P.registerArg(oStringCmmd); 33 | P.registerArg(iStringCmmd); 34 | P.registerArg(mLenCmmd); 35 | P.registerArg(mIdCmmd); 36 | P.registerArg(dupCmmd); 37 | //P.registerArg(lQoffCmmd); 38 | //P.registerArg(lToffCmmd); 39 | 40 | P.parse(); 41 | 42 | // String sQuery = P.GetStringValueFor(aStringCmmd); 43 | //String sTarget = P.GetStringValueFor(bStringCmmd); 44 | string input = P.GetStringValueFor(iStringCmmd); 45 | string output = P.GetStringValueFor(oStringCmmd); 46 | 47 | int minLenForce = P.GetIntValueFor(mLenCmmd); 48 | double minIdentForce = P.GetDoubleValueFor(mIdCmmd); 49 | bool bDup = P.GetBoolValueFor(dupCmmd); 50 | 51 | //int t_offset = P.GetIntValueFor(lToffCmmd); 52 | //int q_offset = P.GetIntValueFor(lQoffCmmd); 53 | 54 | 55 | 56 | int i, j, k; 57 | 58 | MultiMatches in, out; 59 | 60 | in.Read(input); 61 | cout << "Done loading." << endl; 62 | 63 | cout << "Total matches: " << in.GetMatchCount() << endl; 64 | 65 | in.Sort(); 66 | in.Collapse(); 67 | 68 | if (bDup) 69 | RunMatchDynProgMult(out, in); 70 | else 71 | RunMatchDynProg(out, in); 72 | 73 | //out.Collapse(); 74 | cout << "Saving result..." << endl; 75 | out.Write(output); 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /extern/RealFFT/Array.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Array.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (Array_HEADER_INCLUDED) 27 | #define Array_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | class Array 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | typedef T DataType; 49 | 50 | Array (); 51 | 52 | inline const DataType & 53 | operator [] (long pos) const; 54 | inline DataType & 55 | operator [] (long pos); 56 | 57 | static inline long 58 | size (); 59 | 60 | 61 | 62 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 63 | 64 | protected: 65 | 66 | 67 | 68 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 69 | 70 | private: 71 | 72 | DataType _data_arr [LEN]; 73 | 74 | 75 | 76 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 77 | 78 | private: 79 | 80 | Array (const Array &other); 81 | Array & operator = (const Array &other); 82 | bool operator == (const Array &other); 83 | bool operator != (const Array &other); 84 | 85 | }; // class Array 86 | 87 | 88 | 89 | #include "Array.hpp" 90 | 91 | 92 | 93 | #endif // Array_HEADER_INCLUDED 94 | 95 | 96 | 97 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 98 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/Array.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Array.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (Array_HEADER_INCLUDED) 27 | #define Array_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | class Array 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | typedef T DataType; 49 | 50 | Array (); 51 | 52 | inline const DataType & 53 | operator [] (long pos) const; 54 | inline DataType & 55 | operator [] (long pos); 56 | 57 | static inline long 58 | size (); 59 | 60 | 61 | 62 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 63 | 64 | protected: 65 | 66 | 67 | 68 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 69 | 70 | private: 71 | 72 | DataType _data_arr [LEN]; 73 | 74 | 75 | 76 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 77 | 78 | private: 79 | 80 | Array (const Array &other); 81 | Array & operator = (const Array &other); 82 | bool operator == (const Array &other); 83 | bool operator != (const Array &other); 84 | 85 | }; // class Array 86 | 87 | 88 | 89 | #include "Array.hpp" 90 | 91 | 92 | 93 | #endif // Array_HEADER_INCLUDED 94 | 95 | 96 | 97 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 98 | -------------------------------------------------------------------------------- /extern/RealFFT/Array.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Array.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (Array_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of Array code header. 28 | #endif 29 | #define Array_CURRENT_CODEHEADER 30 | 31 | #if ! defined (Array_CODEHEADER_INCLUDED) 32 | #define Array_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include 39 | 40 | 41 | 42 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 | 44 | 45 | 46 | template 47 | Array ::Array () 48 | { 49 | // Nothing 50 | } 51 | 52 | 53 | 54 | template 55 | const typename Array ::DataType & Array ::operator [] (long pos) const 56 | { 57 | assert (pos >= 0); 58 | assert (pos < LEN); 59 | 60 | return (_data_arr [pos]); 61 | } 62 | 63 | 64 | 65 | template 66 | typename Array ::DataType & Array ::operator [] (long pos) 67 | { 68 | assert (pos >= 0); 69 | assert (pos < LEN); 70 | 71 | return (_data_arr [pos]); 72 | } 73 | 74 | 75 | 76 | template 77 | long Array ::size () 78 | { 79 | return (LEN); 80 | } 81 | 82 | 83 | 84 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 85 | 86 | 87 | 88 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 89 | 90 | 91 | 92 | #endif // Array_CODEHEADER_INCLUDED 93 | 94 | #undef Array_CURRENT_CODEHEADER 95 | 96 | 97 | 98 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 99 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/Array.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Array.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (Array_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of Array code header. 28 | #endif 29 | #define Array_CURRENT_CODEHEADER 30 | 31 | #if ! defined (Array_CODEHEADER_INCLUDED) 32 | #define Array_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include 39 | 40 | 41 | 42 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 | 44 | 45 | 46 | template 47 | Array ::Array () 48 | { 49 | // Nothing 50 | } 51 | 52 | 53 | 54 | template 55 | const typename Array ::DataType & Array ::operator [] (long pos) const 56 | { 57 | assert (pos >= 0); 58 | assert (pos < LEN); 59 | 60 | return (_data_arr [pos]); 61 | } 62 | 63 | 64 | 65 | template 66 | typename Array ::DataType & Array ::operator [] (long pos) 67 | { 68 | assert (pos >= 0); 69 | assert (pos < LEN); 70 | 71 | return (_data_arr [pos]); 72 | } 73 | 74 | 75 | 76 | template 77 | long Array ::size () 78 | { 79 | return (LEN); 80 | } 81 | 82 | 83 | 84 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 85 | 86 | 87 | 88 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 89 | 90 | 91 | 92 | #endif // Array_CODEHEADER_INCLUDED 93 | 94 | #undef Array_CURRENT_CODEHEADER 95 | 96 | 97 | 98 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 99 | -------------------------------------------------------------------------------- /tools/src/AlignmentBlock.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include 6 | #include "AlignmentBlock.h" 7 | 8 | //===================================================================== 9 | 10 | string AlignmentBlock::toString() const{ 11 | stringstream outStream; 12 | outStream << "Target: " << getTargetChrom() << ":" << getTargetStart() << "-" << getTargetStop() 13 | << " Query: " << getQueryChrom() << ":" << getQueryStart() << "-" << getQueryStop(); 14 | return outStream.str(); 15 | } 16 | 17 | void AlignmentBlock::print() const { cout << toString() << endl; } 18 | 19 | bool AlignmentBlock::parse(FlatFileParser& parser, bool flip) { 20 | if(!parser.ParseLine()) { return false; } 21 | //cout << "Next block: " << parser.Line() << endl; 22 | 23 | if (flip) { 24 | queryChrom = parser.AsString(0); 25 | targetChrom = parser.AsString(3); 26 | queryStart = parser.AsInt(1); 27 | queryStop = parser.AsInt(2); 28 | targetStart = parser.AsInt(4); 29 | targetStop = parser.AsInt(5); 30 | orientation = parser.AsChar(7); 31 | } else { 32 | targetChrom = parser.AsString(0); 33 | queryChrom = parser.AsString(3); 34 | targetStart = parser.AsInt(1); 35 | targetStop = parser.AsInt(2); 36 | queryStart = parser.AsInt(4); 37 | queryStop = parser.AsInt(5); 38 | orientation = parser.AsChar(7); 39 | } 40 | 41 | if (targetStop - targetStart > 10000) 42 | targetStop = targetStart + 100; 43 | if (queryStop - queryStart > 10000) 44 | queryStop = queryStart + 100; 45 | 46 | return true; 47 | } 48 | 49 | bool AlignmentBlock::merge(const AlignmentBlock& toMerge, int mergeBoundary) { 50 | // Make sure the alignment blocks are from the same chromosomes and orientation & boundary condition is satisfied 51 | if (isCompatible(toMerge) && isWithinBound(targetStop, toMerge.targetStart, mergeBoundary) 52 | && isWithinBound(queryStop, toMerge.queryStart, mergeBoundary)) { 53 | targetStop = max(targetStop, toMerge.targetStop); 54 | queryStop = max(queryStop, toMerge.queryStop); 55 | return true; 56 | } else { 57 | return false; 58 | } 59 | } 60 | 61 | bool AlignmentBlock::isWithinBound(int num1, int num2, int mergeBoundary) { 62 | return (num1 <= num2 + mergeBoundary && num1 >= num2 - mergeBoundary); 63 | } 64 | 65 | bool AlignmentBlock::isCompatible(const AlignmentBlock& otherBlock)const { 66 | if (targetChrom == otherBlock.getTargetChrom() 67 | && queryChrom == otherBlock.queryChrom 68 | && orientation == otherBlock.orientation) { 69 | return true; 70 | } else { 71 | return false; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /extern/RealFFT/TestWhiteNoiseGen.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestWhiteNoiseGen.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (TestWhiteNoiseGen_HEADER_INCLUDED) 27 | #define TestWhiteNoiseGen_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | class TestWhiteNoiseGen 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | typedef DT DataType; 49 | 50 | TestWhiteNoiseGen (); 51 | virtual ~TestWhiteNoiseGen () {} 52 | 53 | void generate (DataType data_ptr [], long len); 54 | 55 | 56 | 57 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 58 | 59 | protected: 60 | 61 | 62 | 63 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 64 | 65 | private: 66 | 67 | typedef unsigned long StateType; 68 | 69 | StateType _rand_state; 70 | 71 | 72 | 73 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 74 | 75 | private: 76 | 77 | TestWhiteNoiseGen (const TestWhiteNoiseGen &other); 78 | TestWhiteNoiseGen & 79 | operator = (const TestWhiteNoiseGen &other); 80 | bool operator == (const TestWhiteNoiseGen &other); 81 | bool operator != (const TestWhiteNoiseGen &other); 82 | 83 | }; // class TestWhiteNoiseGen 84 | 85 | 86 | 87 | #include "TestWhiteNoiseGen.hpp" 88 | 89 | 90 | 91 | #endif // TestWhiteNoiseGen_HEADER_INCLUDED 92 | 93 | 94 | 95 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 96 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/TestWhiteNoiseGen.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestWhiteNoiseGen.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (TestWhiteNoiseGen_HEADER_INCLUDED) 27 | #define TestWhiteNoiseGen_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | class TestWhiteNoiseGen 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | typedef DT DataType; 49 | 50 | TestWhiteNoiseGen (); 51 | virtual ~TestWhiteNoiseGen () {} 52 | 53 | void generate (DataType data_ptr [], long len); 54 | 55 | 56 | 57 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 58 | 59 | protected: 60 | 61 | 62 | 63 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 64 | 65 | private: 66 | 67 | typedef unsigned long StateType; 68 | 69 | StateType _rand_state; 70 | 71 | 72 | 73 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 74 | 75 | private: 76 | 77 | TestWhiteNoiseGen (const TestWhiteNoiseGen &other); 78 | TestWhiteNoiseGen & 79 | operator = (const TestWhiteNoiseGen &other); 80 | bool operator == (const TestWhiteNoiseGen &other); 81 | bool operator != (const TestWhiteNoiseGen &other); 82 | 83 | }; // class TestWhiteNoiseGen 84 | 85 | 86 | 87 | #include "TestWhiteNoiseGen.hpp" 88 | 89 | 90 | 91 | #endif // TestWhiteNoiseGen_HEADER_INCLUDED 92 | 93 | 94 | 95 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 96 | -------------------------------------------------------------------------------- /extern/RealFFT/TestHelperFixLen.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestHelperFixLen.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (TestHelperFixLen_HEADER_INCLUDED) 27 | #define TestHelperFixLen_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "extern/RealFFT/FFTRealFixLen.h" 39 | 40 | 41 | 42 | template 43 | class TestHelperFixLen 44 | { 45 | 46 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 47 | 48 | public: 49 | 50 | typedef FFTRealFixLen FftType; 51 | 52 | static void perform_test_accuracy (int &ret_val); 53 | static void perform_test_speed (int &ret_val); 54 | 55 | 56 | 57 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 58 | 59 | protected: 60 | 61 | 62 | 63 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 64 | 65 | private: 66 | 67 | 68 | 69 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 70 | 71 | private: 72 | 73 | TestHelperFixLen (); 74 | ~TestHelperFixLen (); 75 | TestHelperFixLen (const TestHelperFixLen &other); 76 | TestHelperFixLen & 77 | operator = (const TestHelperFixLen &other); 78 | bool operator == (const TestHelperFixLen &other); 79 | bool operator != (const TestHelperFixLen &other); 80 | 81 | }; // class TestHelperFixLen 82 | 83 | 84 | 85 | #include "TestHelperFixLen.hpp" 86 | 87 | 88 | 89 | #endif // TestHelperFixLen_HEADER_INCLUDED 90 | 91 | 92 | 93 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 94 | -------------------------------------------------------------------------------- /extern/RealFFT/FFTRealUseTrigo.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealUseTrigo.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (FFTRealUseTrigo_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of FFTRealUseTrigo code header. 28 | #endif 29 | #define FFTRealUseTrigo_CURRENT_CODEHEADER 30 | 31 | #if ! defined (FFTRealUseTrigo_CODEHEADER_INCLUDED) 32 | #define FFTRealUseTrigo_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "OscSinCos.h" 39 | 40 | 41 | 42 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 | 44 | 45 | 46 | template 47 | void FFTRealUseTrigo ::prepare (OscType &osc) 48 | { 49 | osc.clear_buffers (); 50 | } 51 | 52 | template <> 53 | void FFTRealUseTrigo <0>::prepare (OscType &osc) 54 | { 55 | // Nothing 56 | } 57 | 58 | 59 | 60 | template 61 | void FFTRealUseTrigo ::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) 62 | { 63 | osc.step (); 64 | c = osc.get_cos (); 65 | s = osc.get_sin (); 66 | } 67 | 68 | template <> 69 | void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) 70 | { 71 | c = cos_ptr [index_c]; 72 | s = cos_ptr [index_s]; 73 | } 74 | 75 | 76 | 77 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | 79 | 80 | 81 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 82 | 83 | 84 | 85 | #endif // FFTRealUseTrigo_CODEHEADER_INCLUDED 86 | 87 | #undef FFTRealUseTrigo_CURRENT_CODEHEADER 88 | 89 | 90 | 91 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 92 | -------------------------------------------------------------------------------- /extern/RealFFT/TestHelperNormal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestHelperNormal.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (TestHelperNormal_HEADER_INCLUDED) 27 | #define TestHelperNormal_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "FFTReal.h" 39 | 40 | 41 | 42 | template 43 | class TestHelperNormal 44 | { 45 | 46 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 47 | 48 | public: 49 | 50 | typedef DT DataType; 51 | typedef FFTReal FftType; 52 | 53 | static void perform_test_accuracy (int &ret_val); 54 | static void perform_test_speed (int &ret_val); 55 | 56 | 57 | 58 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 59 | 60 | protected: 61 | 62 | 63 | 64 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 65 | 66 | private: 67 | 68 | 69 | 70 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | 72 | private: 73 | 74 | TestHelperNormal (); 75 | ~TestHelperNormal (); 76 | TestHelperNormal (const TestHelperNormal &other); 77 | TestHelperNormal & 78 | operator = (const TestHelperNormal &other); 79 | bool operator == (const TestHelperNormal &other); 80 | bool operator != (const TestHelperNormal &other); 81 | 82 | }; // class TestHelperNormal 83 | 84 | 85 | 86 | #include "TestHelperNormal.hpp" 87 | 88 | 89 | 90 | #endif // TestHelperNormal_HEADER_INCLUDED 91 | 92 | 93 | 94 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 95 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/TestHelperFixLen.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestHelperFixLen.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (TestHelperFixLen_HEADER_INCLUDED) 27 | #define TestHelperFixLen_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "extern/RealFFT/FFTRealFixLen.h" 39 | 40 | 41 | 42 | template 43 | class TestHelperFixLen 44 | { 45 | 46 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 47 | 48 | public: 49 | 50 | typedef FFTRealFixLen FftType; 51 | 52 | static void perform_test_accuracy (int &ret_val); 53 | static void perform_test_speed (int &ret_val); 54 | 55 | 56 | 57 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 58 | 59 | protected: 60 | 61 | 62 | 63 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 64 | 65 | private: 66 | 67 | 68 | 69 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 70 | 71 | private: 72 | 73 | TestHelperFixLen (); 74 | ~TestHelperFixLen (); 75 | TestHelperFixLen (const TestHelperFixLen &other); 76 | TestHelperFixLen & 77 | operator = (const TestHelperFixLen &other); 78 | bool operator == (const TestHelperFixLen &other); 79 | bool operator != (const TestHelperFixLen &other); 80 | 81 | }; // class TestHelperFixLen 82 | 83 | 84 | 85 | #include "TestHelperFixLen.hpp" 86 | 87 | 88 | 89 | #endif // TestHelperFixLen_HEADER_INCLUDED 90 | 91 | 92 | 93 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 94 | -------------------------------------------------------------------------------- /extern/RealFFT/TestHelperFixLen.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestHelperFixLen.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (TestHelperFixLen_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of TestHelperFixLen code header. 28 | #endif 29 | #define TestHelperFixLen_CURRENT_CODEHEADER 30 | 31 | #if ! defined (TestHelperFixLen_CODEHEADER_INCLUDED) 32 | #define TestHelperFixLen_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "test_settings.h" 39 | 40 | #include "TestAccuracy.h" 41 | #if defined (test_settings_SPEED_TEST_ENABLED) 42 | #include "TestSpeed.h" 43 | #endif 44 | 45 | 46 | 47 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 48 | 49 | 50 | 51 | template 52 | void TestHelperFixLen ::perform_test_accuracy (int &ret_val) 53 | { 54 | if (ret_val == 0) 55 | { 56 | FftType fft; 57 | ret_val = TestAccuracy ::perform_test_single_object (fft); 58 | } 59 | } 60 | 61 | 62 | 63 | template 64 | void TestHelperFixLen ::perform_test_speed (int &ret_val) 65 | { 66 | #if defined (test_settings_SPEED_TEST_ENABLED) 67 | 68 | if (ret_val == 0) 69 | { 70 | FftType fft; 71 | ret_val = TestSpeed ::perform_test_single_object (fft); 72 | } 73 | 74 | #endif 75 | } 76 | 77 | 78 | 79 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | 82 | 83 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 84 | 85 | 86 | 87 | #endif // TestHelperFixLen_CODEHEADER_INCLUDED 88 | 89 | #undef TestHelperFixLen_CURRENT_CODEHEADER 90 | 91 | 92 | 93 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 94 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/FFTRealUseTrigo.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealUseTrigo.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (FFTRealUseTrigo_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of FFTRealUseTrigo code header. 28 | #endif 29 | #define FFTRealUseTrigo_CURRENT_CODEHEADER 30 | 31 | #if ! defined (FFTRealUseTrigo_CODEHEADER_INCLUDED) 32 | #define FFTRealUseTrigo_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "OscSinCos.h" 39 | 40 | 41 | 42 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 | 44 | 45 | 46 | template 47 | void FFTRealUseTrigo ::prepare (OscType &osc) 48 | { 49 | osc.clear_buffers (); 50 | } 51 | 52 | template <> 53 | void FFTRealUseTrigo <0>::prepare (OscType &osc) 54 | { 55 | // Nothing 56 | } 57 | 58 | 59 | 60 | template 61 | void FFTRealUseTrigo ::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) 62 | { 63 | osc.step (); 64 | c = osc.get_cos (); 65 | s = osc.get_sin (); 66 | } 67 | 68 | template <> 69 | void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) 70 | { 71 | c = cos_ptr [index_c]; 72 | s = cos_ptr [index_s]; 73 | } 74 | 75 | 76 | 77 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | 79 | 80 | 81 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 82 | 83 | 84 | 85 | #endif // FFTRealUseTrigo_CODEHEADER_INCLUDED 86 | 87 | #undef FFTRealUseTrigo_CURRENT_CODEHEADER 88 | 89 | 90 | 91 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 92 | -------------------------------------------------------------------------------- /tools/util/checkLock.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int lock_reg(int fd, int cmd, int type, off_t offset, int whence, off_t len) 13 | { 14 | struct flock lock; 15 | lock.l_type = type; 16 | lock.l_start = offset; 17 | lock.l_whence = whence; 18 | lock.l_len = len; 19 | return fcntl(fd, cmd, &lock); 20 | } 21 | 22 | pid_t lock_test(int fd, int type, off_t offset, int whence, off_t len) 23 | { 24 | struct flock lock; 25 | int ret; 26 | lock.l_type = type; 27 | lock.l_start = offset; 28 | lock.l_whence = whence; 29 | lock.l_len = len; 30 | ret = fcntl(fd, F_GETLK, &lock); 31 | if (ret<0) { 32 | printf("lock_test: fcntl F_GETLK call returned %d\n", ret); 33 | return ret; 34 | } 35 | if (lock.l_type==F_UNLCK) 36 | return 0; 37 | // Make sure we don't return a confusing PID (in case PID not set 38 | // correctly by system). 39 | return (lock.l_pid==0) ? 1 : lock.l_pid; 40 | } 41 | 42 | 43 | int main(int argc, char **argv) { 44 | 45 | int ret = 0; 46 | int fid; 47 | if (argc<2) { 48 | printf("Usage: checkLock filename\n" 49 | "Checks for ability to get advisory write lock on file filename.\n" 50 | "Returns 0 on success, 1 on failure.\n" 51 | "--checkSetLock option: Print warning if setting lock fails.\n"); 52 | return -1; 53 | } 54 | if (0==strcmp("--checkSetLock",argv[1])) { 55 | // Check setting lock 56 | const char filename[] = "/proc/self/exe"; 57 | int fid = open(filename, O_RDONLY, 0); 58 | if (fid>=0) { 59 | ret = lock_reg(fid, F_SETLK, F_RDLCK, 0, SEEK_SET, 0); 60 | if (ret<0) { 61 | printf("WARNING: fcntl locks are not working.\nRunning processes are not" 62 | " protected against overwrite from other computers.\n" 63 | "fcntl call returned %d\n", ret); 64 | return 0; 65 | } 66 | lock_reg(fid, F_SETLK, F_UNLCK, 0, SEEK_SET, 0); 67 | close(fid); 68 | } 69 | return 0; 70 | } else { 71 | // Check whether lock is set on specified file 72 | fid = open(argv[1], O_RDONLY, 0); 73 | if (fid>0) { 74 | ret = lock_test(fid, F_WRLCK, 0, SEEK_SET, 0); 75 | if (ret==1) // special return code for unknown PID case 76 | printf("checkLock: File %s is locked.\n", argv[1]); 77 | else if (ret>0) 78 | printf("checkLock: File %s is locked by PID %d\n", argv[1], ret); 79 | close(fid); 80 | } else { 81 | if ( errno != ENOENT ) { 82 | printf("File %s can't be opened: %s\n", argv[1], strerror(errno) ); 83 | ret = 1; 84 | } 85 | } 86 | return (ret!=0 ? 1 : 0); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/TestHelperFixLen.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestHelperFixLen.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (TestHelperFixLen_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of TestHelperFixLen code header. 28 | #endif 29 | #define TestHelperFixLen_CURRENT_CODEHEADER 30 | 31 | #if ! defined (TestHelperFixLen_CODEHEADER_INCLUDED) 32 | #define TestHelperFixLen_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "test_settings.h" 39 | 40 | #include "TestAccuracy.h" 41 | #if defined (test_settings_SPEED_TEST_ENABLED) 42 | #include "TestSpeed.h" 43 | #endif 44 | 45 | 46 | 47 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 48 | 49 | 50 | 51 | template 52 | void TestHelperFixLen ::perform_test_accuracy (int &ret_val) 53 | { 54 | if (ret_val == 0) 55 | { 56 | FftType fft; 57 | ret_val = TestAccuracy ::perform_test_single_object (fft); 58 | } 59 | } 60 | 61 | 62 | 63 | template 64 | void TestHelperFixLen ::perform_test_speed (int &ret_val) 65 | { 66 | #if defined (test_settings_SPEED_TEST_ENABLED) 67 | 68 | if (ret_val == 0) 69 | { 70 | FftType fft; 71 | ret_val = TestSpeed ::perform_test_single_object (fft); 72 | } 73 | 74 | #endif 75 | } 76 | 77 | 78 | 79 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | 82 | 83 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 84 | 85 | 86 | 87 | #endif // TestHelperFixLen_CODEHEADER_INCLUDED 88 | 89 | #undef TestHelperFixLen_CURRENT_CODEHEADER 90 | 91 | 92 | 93 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 94 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/TestHelperNormal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestHelperNormal.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (TestHelperNormal_HEADER_INCLUDED) 27 | #define TestHelperNormal_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "FFTReal.h" 39 | 40 | 41 | 42 | template 43 | class TestHelperNormal 44 | { 45 | 46 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 47 | 48 | public: 49 | 50 | typedef DT DataType; 51 | typedef FFTReal FftType; 52 | 53 | static void perform_test_accuracy (int &ret_val); 54 | static void perform_test_speed (int &ret_val); 55 | 56 | 57 | 58 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 59 | 60 | protected: 61 | 62 | 63 | 64 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 65 | 66 | private: 67 | 68 | 69 | 70 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | 72 | private: 73 | 74 | TestHelperNormal (); 75 | ~TestHelperNormal (); 76 | TestHelperNormal (const TestHelperNormal &other); 77 | TestHelperNormal & 78 | operator = (const TestHelperNormal &other); 79 | bool operator == (const TestHelperNormal &other); 80 | bool operator != (const TestHelperNormal &other); 81 | 82 | }; // class TestHelperNormal 83 | 84 | 85 | 86 | #include "TestHelperNormal.hpp" 87 | 88 | 89 | 90 | #endif // TestHelperNormal_HEADER_INCLUDED 91 | 92 | 93 | 94 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 95 | -------------------------------------------------------------------------------- /tools/src/Cola/AlignmentCola.h: -------------------------------------------------------------------------------- 1 | #ifndef _ALIGNMENT_COLA_H_ 2 | #define _ALIGNMENT_COLA_H_ 3 | 4 | 5 | #include "../Alignment.h" 6 | #include "EditGraph.h" 7 | #include "AlignerParams.h" 8 | 9 | #define GAP_CHAR '-' 10 | #define MATCH_CHAR '|' 11 | #define MISMATCH_CHAR ' ' 12 | 13 | 14 | //=================================================================== 15 | /** 16 | * Alignment class represents an alignment, which can be created from an aligned editGraph 17 | * The alignment can be represented by the one editgraphNode or by backtracing this and 18 | * finding the aligned sequence coordinates. 19 | */ 20 | class AlignmentCola:public Alignment 21 | { 22 | public: 23 | 24 | // Ctor - Can be used as default with no params or given as many of the params in order as available 25 | AlignmentCola(const DNAVector& tSeq = DNAVector(), const DNAVector& qSeq = DNAVector(), 26 | const AlignerParams& p = AlignerParams()) 27 | :Alignment(tSeq,qSeq), pathNodes(), params(p) {} 28 | 29 | virtual ~AlignmentCola() {} 30 | 31 | /** Get the number of elements in the alignment (i.e. alignment length) */ 32 | int getLength() const { return pathNodes.size(); } 33 | 34 | /** 35 | * Add node to the optimal path nodes 36 | */ 37 | void addNodeToPath(EditGraphNode* node); 38 | 39 | /** 40 | * Produce alignment from the path nodes 41 | * @parameter - choose whether beginning part of alignment that has negative score is traced 42 | */ 43 | void traceAlignment(bool tracePrefix = false); 44 | 45 | /** 46 | * Confines the existing alignment to the start/end boundaries 47 | * Used for only keeping the alignment from start to end points 48 | * and discarding the rest. 49 | * All fields of alignment/info will be updated accordingly 50 | */ 51 | void keepSubalignment(int start, int end); 52 | 53 | /** 54 | * Return the significance (P-Value) of the similarity or identity score: 55 | * This is done based on an empirical model of the expected score 56 | * as a function of the length of the alignment and assumption 57 | * of an underlying binomial distribution estimated by the findColaSigDist module 58 | */ 59 | virtual double calcPVal() const; 60 | 61 | virtual void printFull(double pValLimit, ostream& sout, int screenWidth, bool withInfo=true) const; 62 | 63 | private: 64 | /** Use to update smith-waterman score after each iteration in finding the alignment path**/ 65 | void updateSWScore(); 66 | 67 | map pathNodes; /// Nodes on the optimal path mapped to increasing value: row+col 68 | AlignerParams params; /// Include the type of aligner and relevant params used for this alignment 69 | }; 70 | 71 | 72 | #endif //_ALIGNMENT_COLA_H_ 73 | 74 | -------------------------------------------------------------------------------- /extern/RealFFT/TestWhiteNoiseGen.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestWhiteNoiseGen.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (TestWhiteNoiseGen_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of TestWhiteNoiseGen code header. 28 | #endif 29 | #define TestWhiteNoiseGen_CURRENT_CODEHEADER 30 | 31 | #if ! defined (TestWhiteNoiseGen_CODEHEADER_INCLUDED) 32 | #define TestWhiteNoiseGen_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 41 | 42 | 43 | 44 | template 45 | TestWhiteNoiseGen

::TestWhiteNoiseGen () 46 | : _rand_state (0) 47 | { 48 | _rand_state = reinterpret_cast (this); 49 | } 50 | 51 | 52 | 53 | template 54 | void TestWhiteNoiseGen
::generate (DataType data_ptr [], long len) 55 | { 56 | assert (data_ptr != 0); 57 | assert (len > 0); 58 | 59 | const DataType one = static_cast (1); 60 | const DataType mul = one / static_cast (0x80000000UL); 61 | 62 | long pos = 0; 63 | do 64 | { 65 | const DataType x = static_cast (_rand_state & 0xFFFFFFFFUL); 66 | data_ptr [pos] = x * mul - one; 67 | 68 | _rand_state = _rand_state * 1234567UL + 890123UL; 69 | 70 | ++ pos; 71 | } 72 | while (pos < len); 73 | } 74 | 75 | 76 | 77 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | 79 | 80 | 81 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 82 | 83 | 84 | 85 | #endif // TestWhiteNoiseGen_CODEHEADER_INCLUDED 86 | 87 | #undef TestWhiteNoiseGen_CURRENT_CODEHEADER 88 | 89 | 90 | 91 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 92 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/TestWhiteNoiseGen.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestWhiteNoiseGen.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (TestWhiteNoiseGen_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of TestWhiteNoiseGen code header. 28 | #endif 29 | #define TestWhiteNoiseGen_CURRENT_CODEHEADER 30 | 31 | #if ! defined (TestWhiteNoiseGen_CODEHEADER_INCLUDED) 32 | #define TestWhiteNoiseGen_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 41 | 42 | 43 | 44 | template 45 | TestWhiteNoiseGen
::TestWhiteNoiseGen () 46 | : _rand_state (0) 47 | { 48 | _rand_state = reinterpret_cast (this); 49 | } 50 | 51 | 52 | 53 | template 54 | void TestWhiteNoiseGen
::generate (DataType data_ptr [], long len) 55 | { 56 | assert (data_ptr != 0); 57 | assert (len > 0); 58 | 59 | const DataType one = static_cast (1); 60 | const DataType mul = one / static_cast (0x80000000UL); 61 | 62 | long pos = 0; 63 | do 64 | { 65 | const DataType x = static_cast (_rand_state & 0xFFFFFFFFUL); 66 | data_ptr [pos] = x * mul - one; 67 | 68 | _rand_state = _rand_state * 1234567UL + 890123UL; 69 | 70 | ++ pos; 71 | } 72 | while (pos < len); 73 | } 74 | 75 | 76 | 77 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | 79 | 80 | 81 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 82 | 83 | 84 | 85 | #endif // TestWhiteNoiseGen_CODEHEADER_INCLUDED 86 | 87 | #undef TestWhiteNoiseGen_CURRENT_CODEHEADER 88 | 89 | 90 | 91 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 92 | -------------------------------------------------------------------------------- /extern/RealFFT/FFTRealFixLenParam.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealFixLenParam.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (FFTRealFixLenParam_HEADER_INCLUDED) 27 | #define FFTRealFixLenParam_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | class FFTRealFixLenParam 41 | { 42 | 43 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 44 | 45 | public: 46 | 47 | // Over this bit depth, we use direct calculation for sin/cos 48 | enum { TRIGO_BD_LIMIT = 12 }; 49 | 50 | typedef float DataType; 51 | 52 | 53 | 54 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 55 | 56 | protected: 57 | 58 | 59 | 60 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 61 | 62 | private: 63 | 64 | 65 | 66 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 67 | 68 | private: 69 | 70 | #if 0 // To avoid GCC warning: 71 | // All member functions in class 'FFTRealFixLenParam' are private 72 | FFTRealFixLenParam (); 73 | ~FFTRealFixLenParam (); 74 | FFTRealFixLenParam (const FFTRealFixLenParam &other); 75 | FFTRealFixLenParam & 76 | operator = (const FFTRealFixLenParam &other); 77 | bool operator == (const FFTRealFixLenParam &other); 78 | bool operator != (const FFTRealFixLenParam &other); 79 | #endif 80 | 81 | }; // class FFTRealFixLenParam 82 | 83 | 84 | 85 | //#include "FFTRealFixLenParam.hpp" 86 | 87 | 88 | 89 | #endif // FFTRealFixLenParam_HEADER_INCLUDED 90 | 91 | 92 | 93 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 94 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/FFTRealFixLenParam.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealFixLenParam.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (FFTRealFixLenParam_HEADER_INCLUDED) 27 | #define FFTRealFixLenParam_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | class FFTRealFixLenParam 41 | { 42 | 43 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 44 | 45 | public: 46 | 47 | // Over this bit depth, we use direct calculation for sin/cos 48 | enum { TRIGO_BD_LIMIT = 12 }; 49 | 50 | typedef float DataType; 51 | 52 | 53 | 54 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 55 | 56 | protected: 57 | 58 | 59 | 60 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 61 | 62 | private: 63 | 64 | 65 | 66 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 67 | 68 | private: 69 | 70 | #if 0 // To avoid GCC warning: 71 | // All member functions in class 'FFTRealFixLenParam' are private 72 | FFTRealFixLenParam (); 73 | ~FFTRealFixLenParam (); 74 | FFTRealFixLenParam (const FFTRealFixLenParam &other); 75 | FFTRealFixLenParam & 76 | operator = (const FFTRealFixLenParam &other); 77 | bool operator == (const FFTRealFixLenParam &other); 78 | bool operator != (const FFTRealFixLenParam &other); 79 | #endif 80 | 81 | }; // class FFTRealFixLenParam 82 | 83 | 84 | 85 | //#include "FFTRealFixLenParam.hpp" 86 | 87 | 88 | 89 | #endif // FFTRealFixLenParam_HEADER_INCLUDED 90 | 91 | 92 | 93 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 94 | -------------------------------------------------------------------------------- /tools/src/Papaya/runPapayaCola.cc: -------------------------------------------------------------------------------- 1 | #ifndef FORCE_DEBUG 2 | #define NDEBUG 3 | #endif 4 | 5 | #include "base/CommandLineParser.h" 6 | #include "src/Papaya/Papaya.h" 7 | 8 | 9 | int main(int argc,char** argv) 10 | { 11 | commandArg targetCmmd("-t","target fasta file"); 12 | commandArg queryCmmd("-q","query fasta file"); 13 | commandArg outCmmd("-o","output file"); 14 | commandArg nCmmd("-n","number of processes", 1); 15 | commandArg numCmmd("-k","number of 12-mers used for seeding", 2); 16 | commandArg wordCmmd("-w","size of a k-mer", 12); 17 | commandArg laCmmd("-la","number of lookahead k-mers", 12); 18 | commandArg skipCmmd("-la_skip","skip k-mers in lookahead", 2); 19 | commandArg selfCmmd("-self","suppress matches to itself (query=target)", false); 20 | commandArg identCmmd("-min","min identity", 0.999); 21 | commandArg maxGapCmmd("-max_gap","maximum gap", 500); 22 | commandArg minCmmd("-min_len","minimum alignment length", 30); 23 | commandArg repCmmd("-noreps","do not align to repeats (soft-masked)", false); 24 | commandLineParser P(argc,argv); 25 | 26 | P.SetDescription("Welcome to Papaya/Cola, alignments with seeds (and more)!"); 27 | 28 | P.registerArg(targetCmmd); 29 | P.registerArg(queryCmmd); 30 | P.registerArg(outCmmd); 31 | P.registerArg(nCmmd); 32 | P.registerArg(numCmmd); 33 | P.registerArg(laCmmd); 34 | P.registerArg(skipCmmd); 35 | P.registerArg(selfCmmd); 36 | P.registerArg(repCmmd); 37 | P.registerArg(wordCmmd); 38 | P.registerArg(maxGapCmmd); 39 | P.registerArg(minCmmd); 40 | P.registerArg(identCmmd); 41 | 42 | P.parse(); 43 | 44 | string targetFile = P.GetStringValueFor(targetCmmd); 45 | string queryFile = P.GetStringValueFor(queryCmmd); 46 | string outFile = P.GetStringValueFor(outCmmd); 47 | int numKmers = P.GetIntValueFor(numCmmd); 48 | int lookAhead = P.GetIntValueFor(laCmmd); 49 | int lookAheadSkip = P.GetIntValueFor(skipCmmd); 50 | int nProc = P.GetIntValueFor(nCmmd); 51 | int wordSize = P.GetIntValueFor(wordCmmd); 52 | bool bSelf = P.GetBoolValueFor(selfCmmd); 53 | bool bNoReps = P.GetBoolValueFor(selfCmmd); 54 | int maxGap = P.GetIntValueFor(maxGapCmmd); 55 | int minLen = P.GetIntValueFor(minCmmd); 56 | double minIdent = P.GetDoubleValueFor(identCmmd); 57 | 58 | 59 | PapayaSeedingParams seedingParams(numKmers, lookAhead, lookAheadSkip, 60 | wordSize, bSelf, bNoReps); 61 | PapayaAlignerParams alignerParams(maxGap, minLen, minIdent); 62 | PapayaAligner pAligner; 63 | pAligner.initialize(targetFile, seedingParams, nProc); 64 | pAligner.processQuery(queryFile, outFile, alignerParams); 65 | 66 | return 0; 67 | 68 | } 69 | 70 | -------------------------------------------------------------------------------- /extern/RealFFT/DynArray.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | DynArray.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (DynArray_HEADER_INCLUDED) 27 | #define DynArray_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | class DynArray 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | typedef T DataType; 49 | 50 | DynArray (); 51 | explicit DynArray (long size); 52 | ~DynArray (); 53 | 54 | inline long size () const; 55 | inline void resize (long size); 56 | 57 | inline const DataType & 58 | operator [] (long pos) const; 59 | inline DataType & 60 | operator [] (long pos); 61 | 62 | 63 | 64 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 65 | 66 | protected: 67 | 68 | 69 | 70 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | 72 | private: 73 | 74 | DataType * _data_ptr; 75 | long _len; 76 | 77 | 78 | 79 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | private: 82 | 83 | DynArray (const DynArray &other); 84 | DynArray & operator = (const DynArray &other); 85 | bool operator == (const DynArray &other); 86 | bool operator != (const DynArray &other); 87 | 88 | }; // class DynArray 89 | 90 | 91 | 92 | #include "DynArray.hpp" 93 | 94 | 95 | 96 | #endif // DynArray_HEADER_INCLUDED 97 | 98 | 99 | 100 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 101 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/DynArray.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | DynArray.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (DynArray_HEADER_INCLUDED) 27 | #define DynArray_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | class DynArray 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | typedef T DataType; 49 | 50 | DynArray (); 51 | explicit DynArray (long size); 52 | ~DynArray (); 53 | 54 | inline long size () const; 55 | inline void resize (long size); 56 | 57 | inline const DataType & 58 | operator [] (long pos) const; 59 | inline DataType & 60 | operator [] (long pos); 61 | 62 | 63 | 64 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 65 | 66 | protected: 67 | 68 | 69 | 70 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | 72 | private: 73 | 74 | DataType * _data_ptr; 75 | long _len; 76 | 77 | 78 | 79 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | private: 82 | 83 | DynArray (const DynArray &other); 84 | DynArray & operator = (const DynArray &other); 85 | bool operator == (const DynArray &other); 86 | bool operator != (const DynArray &other); 87 | 88 | }; // class DynArray 89 | 90 | 91 | 92 | #include "DynArray.hpp" 93 | 94 | 95 | 96 | #endif // DynArray_HEADER_INCLUDED 97 | 98 | 99 | 100 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 101 | -------------------------------------------------------------------------------- /extern/RealFFT/TestSpeed.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestSpeed.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (TestSpeed_HEADER_INCLUDED) 27 | #define TestSpeed_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | class TestSpeed 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | typedef typename FO::DataType DataType; 49 | 50 | static int perform_test_single_object (FO &fft); 51 | static int perform_test_d (FO &fft, const char *class_name_0); 52 | static int perform_test_i (FO &fft, const char *class_name_0); 53 | static int perform_test_di (FO &fft, const char *class_name_0); 54 | 55 | 56 | 57 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 58 | 59 | protected: 60 | 61 | 62 | 63 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 64 | 65 | private: 66 | 67 | enum { NBR_SPD_TESTS = 10 * 1000 * 1000 }; 68 | enum { MAX_NBR_TESTS = 10000 }; 69 | 70 | 71 | 72 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 73 | 74 | private: 75 | 76 | TestSpeed (); 77 | ~TestSpeed (); 78 | TestSpeed (const TestSpeed &other); 79 | TestSpeed & operator = (const TestSpeed &other); 80 | bool operator == (const TestSpeed &other); 81 | bool operator != (const TestSpeed &other); 82 | 83 | }; // class TestSpeed 84 | 85 | 86 | 87 | #include "TestSpeed.hpp" 88 | 89 | 90 | 91 | #endif // TestSpeed_HEADER_INCLUDED 92 | 93 | 94 | 95 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 96 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/TestSpeed.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestSpeed.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (TestSpeed_HEADER_INCLUDED) 27 | #define TestSpeed_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | template 41 | class TestSpeed 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | typedef typename FO::DataType DataType; 49 | 50 | static int perform_test_single_object (FO &fft); 51 | static int perform_test_d (FO &fft, const char *class_name_0); 52 | static int perform_test_i (FO &fft, const char *class_name_0); 53 | static int perform_test_di (FO &fft, const char *class_name_0); 54 | 55 | 56 | 57 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 58 | 59 | protected: 60 | 61 | 62 | 63 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 64 | 65 | private: 66 | 67 | enum { NBR_SPD_TESTS = 10 * 1000 * 1000 }; 68 | enum { MAX_NBR_TESTS = 10000 }; 69 | 70 | 71 | 72 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 73 | 74 | private: 75 | 76 | TestSpeed (); 77 | ~TestSpeed (); 78 | TestSpeed (const TestSpeed &other); 79 | TestSpeed & operator = (const TestSpeed &other); 80 | bool operator == (const TestSpeed &other); 81 | bool operator != (const TestSpeed &other); 82 | 83 | }; // class TestSpeed 84 | 85 | 86 | 87 | #include "TestSpeed.hpp" 88 | 89 | 90 | 91 | #endif // TestSpeed_HEADER_INCLUDED 92 | 93 | 94 | 95 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 96 | -------------------------------------------------------------------------------- /tools/extern/easel/esl_stats.cc: -------------------------------------------------------------------------------- 1 | /* Foundation for the statistics modules. 2 | * 3 | * Contents: 4 | * 1. The stats API. 5 | * 2. Unit tests. 6 | * 3. Test driver. 7 | * 4. Example. 8 | * 5. License and copyright information. 9 | * 10 | */ 11 | #include 12 | 13 | #include "extern/easel/easel.h" 14 | #include "extern/easel/esl_stats.h" 15 | 16 | 17 | /* Function: esl_stats_DMean() 18 | * Synopsis: Calculates mean and $\sigma^2$ for samples $x_i$. 19 | * Incept: SRE, Tue Jul 19 11:04:00 2005 [St. Louis] 20 | * 21 | * Purpose: Calculates the sample mean and $s^2$, the unbiased 22 | * estimator of the population variance, for a 23 | * sample of numbers , and optionally 24 | * returns either or both through and 25 | * . 26 | * 27 | * and do the same, 28 | * for float and integer vectors. 29 | * 30 | * Args: x - samples x[0]..x[n-1] 31 | * n - number of samples 32 | * opt_mean - optRETURN: mean 33 | * opt_var - optRETURN: estimate of population variance 34 | * 35 | * Returns: on success. 36 | */ 37 | int 38 | esl_stats_DMean(const double *x, int n, double *opt_mean, double *opt_var) 39 | { 40 | double sum = 0.; 41 | double sqsum = 0.; 42 | int i; 43 | 44 | for (i = 0; i < n; i++) 45 | { 46 | sum += x[i]; 47 | sqsum += x[i]*x[i]; 48 | } 49 | if (opt_mean != NULL) *opt_mean = sum / (double) n; 50 | if (opt_var != NULL) *opt_var = (sqsum - sum*sum/(double)n) / ((double)n-1); 51 | return eslOK; 52 | } 53 | int 54 | esl_stats_FMean(const float *x, int n, double *opt_mean, double *opt_var) 55 | { 56 | double sum = 0.; 57 | double sqsum = 0.; 58 | int i; 59 | 60 | for (i = 0; i < n; i++) 61 | { 62 | sum += x[i]; 63 | sqsum += x[i]*x[i]; 64 | } 65 | if (opt_mean != NULL) *opt_mean = sum / (double) n; 66 | if (opt_var != NULL) *opt_var = (sqsum - sum*sum/(double)n) / ((double)n-1); 67 | return eslOK; 68 | } 69 | int 70 | esl_stats_IMean(const int *x, int n, double *opt_mean, double *opt_var) 71 | { 72 | double sum = 0.; 73 | double sqsum = 0.; 74 | int i; 75 | 76 | for (i = 0; i < n; i++) 77 | { 78 | sum += x[i]; 79 | sqsum += x[i]*x[i]; 80 | } 81 | if (opt_mean != NULL) *opt_mean = sum / (double) n; 82 | if (opt_var != NULL) *opt_var = (sqsum - sum*sum/(double)n) / ((double)n-1); 83 | return eslOK; 84 | } 85 | 86 | /***************************************************************** 87 | * @LICENSE@ 88 | * 89 | * SVN $Id: esl_stats.c 685 2011-05-23 14:27:52Z eddys $ 90 | * SVN $URL: https://svn.janelia.org/eddylab/eddys/easel/trunk/esl_stats.c $ 91 | *****************************************************************/ 92 | -------------------------------------------------------------------------------- /extern/RealFFT/FFTRealPassDirect.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealPassDirect.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (FFTRealPassDirect_HEADER_INCLUDED) 27 | #define FFTRealPassDirect_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "extern/RealFFT/def.h" 39 | #include "extern/RealFFT/FFTRealFixLenParam.h" 40 | #include "extern/RealFFT/OscSinCos.h" 41 | 42 | 43 | 44 | template 45 | class FFTRealPassDirect 46 | { 47 | 48 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 49 | 50 | public: 51 | 52 | typedef FFTRealFixLenParam::DataType DataType; 53 | typedef OscSinCos OscType; 54 | 55 | FORCEINLINE static void 56 | process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); 57 | 58 | 59 | 60 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 61 | 62 | protected: 63 | 64 | 65 | 66 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 67 | 68 | private: 69 | 70 | 71 | 72 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 73 | 74 | private: 75 | 76 | FFTRealPassDirect (); 77 | ~FFTRealPassDirect (); 78 | FFTRealPassDirect (const FFTRealPassDirect &other); 79 | FFTRealPassDirect & 80 | operator = (const FFTRealPassDirect &other); 81 | bool operator == (const FFTRealPassDirect &other); 82 | bool operator != (const FFTRealPassDirect &other); 83 | 84 | }; // class FFTRealPassDirect 85 | 86 | 87 | 88 | #include "extern/RealFFT/FFTRealPassDirect.hpp" 89 | 90 | 91 | 92 | #endif // FFTRealPassDirect_HEADER_INCLUDED 93 | 94 | 95 | 96 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 97 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/FFTRealPassDirect.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealPassDirect.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (FFTRealPassDirect_HEADER_INCLUDED) 27 | #define FFTRealPassDirect_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "extern/RealFFT/def.h" 39 | #include "extern/RealFFT/FFTRealFixLenParam.h" 40 | #include "extern/RealFFT/OscSinCos.h" 41 | 42 | 43 | 44 | template 45 | class FFTRealPassDirect 46 | { 47 | 48 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 49 | 50 | public: 51 | 52 | typedef FFTRealFixLenParam::DataType DataType; 53 | typedef OscSinCos OscType; 54 | 55 | FORCEINLINE static void 56 | process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); 57 | 58 | 59 | 60 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 61 | 62 | protected: 63 | 64 | 65 | 66 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 67 | 68 | private: 69 | 70 | 71 | 72 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 73 | 74 | private: 75 | 76 | FFTRealPassDirect (); 77 | ~FFTRealPassDirect (); 78 | FFTRealPassDirect (const FFTRealPassDirect &other); 79 | FFTRealPassDirect & 80 | operator = (const FFTRealPassDirect &other); 81 | bool operator == (const FFTRealPassDirect &other); 82 | bool operator != (const FFTRealPassDirect &other); 83 | 84 | }; // class FFTRealPassDirect 85 | 86 | 87 | 88 | #include "extern/RealFFT/FFTRealPassDirect.hpp" 89 | 90 | 91 | 92 | #endif // FFTRealPassDirect_HEADER_INCLUDED 93 | 94 | 95 | 96 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 97 | -------------------------------------------------------------------------------- /extern/RealFFT/OscSinCos.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | OscSinCos.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (OscSinCos_HEADER_INCLUDED) 27 | #define OscSinCos_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "def.h" 39 | 40 | 41 | 42 | template 43 | class OscSinCos 44 | { 45 | 46 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 47 | 48 | public: 49 | 50 | typedef T DataType; 51 | 52 | OscSinCos (); 53 | 54 | FORCEINLINE void 55 | set_step (double angle_rad); 56 | 57 | FORCEINLINE DataType 58 | get_cos () const; 59 | FORCEINLINE DataType 60 | get_sin () const; 61 | FORCEINLINE void 62 | step (); 63 | FORCEINLINE void 64 | clear_buffers (); 65 | 66 | 67 | 68 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 69 | 70 | protected: 71 | 72 | 73 | 74 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 75 | 76 | private: 77 | 78 | DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] 79 | DataType _pos_sin; // - 80 | DataType _step_cos; // Phase increment per step, [-1 ; 1] 81 | DataType _step_sin; // - 82 | 83 | 84 | 85 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 86 | 87 | private: 88 | 89 | OscSinCos (const OscSinCos &other); 90 | OscSinCos & operator = (const OscSinCos &other); 91 | bool operator == (const OscSinCos &other); 92 | bool operator != (const OscSinCos &other); 93 | 94 | }; // class OscSinCos 95 | 96 | 97 | 98 | #include "OscSinCos.hpp" 99 | 100 | 101 | 102 | #endif // OscSinCos_HEADER_INCLUDED 103 | 104 | 105 | 106 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 107 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/OscSinCos.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | OscSinCos.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if ! defined (OscSinCos_HEADER_INCLUDED) 27 | #define OscSinCos_HEADER_INCLUDED 28 | 29 | #if defined (_MSC_VER) 30 | #pragma once 31 | #pragma warning (4 : 4250) // "Inherits via dominance." 32 | #endif 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "def.h" 39 | 40 | 41 | 42 | template 43 | class OscSinCos 44 | { 45 | 46 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 47 | 48 | public: 49 | 50 | typedef T DataType; 51 | 52 | OscSinCos (); 53 | 54 | FORCEINLINE void 55 | set_step (double angle_rad); 56 | 57 | FORCEINLINE DataType 58 | get_cos () const; 59 | FORCEINLINE DataType 60 | get_sin () const; 61 | FORCEINLINE void 62 | step (); 63 | FORCEINLINE void 64 | clear_buffers (); 65 | 66 | 67 | 68 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 69 | 70 | protected: 71 | 72 | 73 | 74 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 75 | 76 | private: 77 | 78 | DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] 79 | DataType _pos_sin; // - 80 | DataType _step_cos; // Phase increment per step, [-1 ; 1] 81 | DataType _step_sin; // - 82 | 83 | 84 | 85 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 86 | 87 | private: 88 | 89 | OscSinCos (const OscSinCos &other); 90 | OscSinCos & operator = (const OscSinCos &other); 91 | bool operator == (const OscSinCos &other); 92 | bool operator != (const OscSinCos &other); 93 | 94 | }; // class OscSinCos 95 | 96 | 97 | 98 | #include "OscSinCos.hpp" 99 | 100 | 101 | 102 | #endif // OscSinCos_HEADER_INCLUDED 103 | 104 | 105 | 106 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 107 | -------------------------------------------------------------------------------- /tools/base/SVector.h: -------------------------------------------------------------------------------- 1 | #ifndef SVECTOR_H_ 2 | #define SVECTOR_H_ 3 | 4 | using namespace std; 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "ErrorHandling.h" 11 | 12 | #define NDEBUG 13 | 14 | template 15 | class svec : public vector 16 | { 17 | public: 18 | 19 | int isize() const {return (int)vector::size();} 20 | long long lsize() const {return vector::size();} 21 | 22 | const T & operator[] (long long i) const { 23 | #ifndef NDEBUG 24 | 25 | if (i>= lsize()) { 26 | cout << "ERROR: i=" << i << " lsize=" << lsize() << endl; 27 | ThrowError("i>=lsize()", "svec"); 28 | } 29 | if (i<0) { 30 | cout << "ERROR: i=" << i << " lsize=" << lsize() << endl; 31 | ThrowError("i<0", "svec"); 32 | } 33 | //assert(i=0); 35 | #endif 36 | return vector::operator[](i); 37 | } 38 | 39 | T & operator[] (long long i) { 40 | #ifndef NDEBUG 41 | if (i>= lsize()) { 42 | cout << "ERROR: i=" << i << " lsize=" << lsize() << endl; 43 | ThrowError("i>=lsize()", "svec"); 44 | } 45 | if (i<0) { 46 | cout << "ERROR: i=" << i << " lsize=" << lsize() << endl; 47 | ThrowError("i<0", "svec"); 48 | } 49 | //assert(i=0); 51 | #endif 52 | return vector::operator[](i); 53 | } 54 | 55 | 56 | 57 | }; 58 | 59 | 60 | template 61 | class vec : public svec 62 | { 63 | }; 64 | 65 | template 66 | void Sort(svec& v) 67 | { 68 | sort(v.begin(), v.end()); 69 | } 70 | 71 | 72 | template 73 | void UniqueSort(svec& v) 74 | { 75 | sort(v.begin(), v.end()); 76 | 77 | long long i; 78 | long long k = 0; 79 | for (i=0; i 90 | long long BinSearch(svec & v, const T & item) 91 | { 92 | typename svec::iterator iter; 93 | typename svec::iterator begin = v.begin(); 94 | typename svec::iterator end = v.end(); 95 | iter = lower_bound(begin, end, item); 96 | long long pos = distance(begin, iter); 97 | 98 | if (pos < 0) 99 | return -1; 100 | 101 | if (pos == v.isize()) 102 | return -1; 103 | 104 | if (v[pos] < item || item < v[pos]) 105 | return -1; 106 | 107 | return pos; 108 | 109 | } 110 | 111 | template 112 | long long BinSearchFuzzy(svec & v, const T & item) 113 | { 114 | typename svec::iterator iter; 115 | typename svec::iterator begin = v.begin(); 116 | typename svec::iterator end = v.end(); 117 | iter = lower_bound(begin, end, item); 118 | long pos = distance(begin, iter); 119 | 120 | if (pos < 0) 121 | return -1; 122 | 123 | return pos; 124 | 125 | } 126 | 127 | 128 | 129 | 130 | #endif //SVECTOR_H_ 131 | 132 | 133 | -------------------------------------------------------------------------------- /extern/RealFFT/FFTRealUseTrigo.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealUseTrigo.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | Template parameters: 7 | - ALGO: algorithm choice. 0 = table, other = oscillator 8 | 9 | --- Legal stuff --- 10 | 11 | This library is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU Lesser General Public 13 | License as published by the Free Software Foundation; either 14 | version 2.1 of the License, or (at your option) any later version. 15 | 16 | This library is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this library; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | *Tab=3***********************************************************************/ 26 | 27 | 28 | 29 | #if ! defined (FFTRealUseTrigo_HEADER_INCLUDED) 30 | #define FFTRealUseTrigo_HEADER_INCLUDED 31 | 32 | #if defined (_MSC_VER) 33 | #pragma once 34 | #pragma warning (4 : 4250) // "Inherits via dominance." 35 | #endif 36 | 37 | 38 | 39 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | #include "extern/RealFFT/def.h" 42 | #include "extern/RealFFT/FFTRealFixLenParam.h" 43 | #include "extern/RealFFT/OscSinCos.h" 44 | 45 | 46 | 47 | template 48 | class FFTRealUseTrigo 49 | { 50 | 51 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 52 | 53 | public: 54 | 55 | typedef FFTRealFixLenParam::DataType DataType; 56 | typedef OscSinCos OscType; 57 | 58 | FORCEINLINE static void 59 | prepare (OscType &osc); 60 | FORCEINLINE static void 61 | iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s); 62 | 63 | 64 | 65 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 66 | 67 | protected: 68 | 69 | 70 | 71 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 72 | 73 | private: 74 | 75 | 76 | 77 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | 79 | private: 80 | 81 | FFTRealUseTrigo (); 82 | ~FFTRealUseTrigo (); 83 | FFTRealUseTrigo (const FFTRealUseTrigo &other); 84 | FFTRealUseTrigo & 85 | operator = (const FFTRealUseTrigo &other); 86 | bool operator == (const FFTRealUseTrigo &other); 87 | bool operator != (const FFTRealUseTrigo &other); 88 | 89 | }; // class FFTRealUseTrigo 90 | 91 | 92 | 93 | #include "FFTRealUseTrigo.hpp" 94 | 95 | 96 | 97 | #endif // FFTRealUseTrigo_HEADER_INCLUDED 98 | 99 | 100 | 101 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 102 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/FFTRealUseTrigo.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FFTRealUseTrigo.h 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | Template parameters: 7 | - ALGO: algorithm choice. 0 = table, other = oscillator 8 | 9 | --- Legal stuff --- 10 | 11 | This library is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU Lesser General Public 13 | License as published by the Free Software Foundation; either 14 | version 2.1 of the License, or (at your option) any later version. 15 | 16 | This library is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this library; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | *Tab=3***********************************************************************/ 26 | 27 | 28 | 29 | #if ! defined (FFTRealUseTrigo_HEADER_INCLUDED) 30 | #define FFTRealUseTrigo_HEADER_INCLUDED 31 | 32 | #if defined (_MSC_VER) 33 | #pragma once 34 | #pragma warning (4 : 4250) // "Inherits via dominance." 35 | #endif 36 | 37 | 38 | 39 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | #include "extern/RealFFT/def.h" 42 | #include "extern/RealFFT/FFTRealFixLenParam.h" 43 | #include "extern/RealFFT/OscSinCos.h" 44 | 45 | 46 | 47 | template 48 | class FFTRealUseTrigo 49 | { 50 | 51 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 52 | 53 | public: 54 | 55 | typedef FFTRealFixLenParam::DataType DataType; 56 | typedef OscSinCos OscType; 57 | 58 | FORCEINLINE static void 59 | prepare (OscType &osc); 60 | FORCEINLINE static void 61 | iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s); 62 | 63 | 64 | 65 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 66 | 67 | protected: 68 | 69 | 70 | 71 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 72 | 73 | private: 74 | 75 | 76 | 77 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | 79 | private: 80 | 81 | FFTRealUseTrigo (); 82 | ~FFTRealUseTrigo (); 83 | FFTRealUseTrigo (const FFTRealUseTrigo &other); 84 | FFTRealUseTrigo & 85 | operator = (const FFTRealUseTrigo &other); 86 | bool operator == (const FFTRealUseTrigo &other); 87 | bool operator != (const FFTRealUseTrigo &other); 88 | 89 | }; // class FFTRealUseTrigo 90 | 91 | 92 | 93 | #include "FFTRealUseTrigo.hpp" 94 | 95 | 96 | 97 | #endif // FFTRealUseTrigo_HEADER_INCLUDED 98 | 99 | 100 | 101 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 102 | -------------------------------------------------------------------------------- /tools/analysis/SeqChunk.h: -------------------------------------------------------------------------------- 1 | #ifndef SEQCHUNK_H_ 2 | #define SEQCHUNK_H_ 3 | 4 | //#include "base/SVector.h" 5 | #include "DNAVector.h" 6 | 7 | 8 | 9 | //================================================================ 10 | 11 | class SeqChunkSelect 12 | { 13 | public: 14 | SeqChunkSelect() {} 15 | 16 | void Read(const string & file); 17 | void Write(const string & file); 18 | void MergeRead(const string & file); 19 | 20 | 21 | int GetQuerySize() const {return m_query.isize();} 22 | int GetTargetSize() const {return m_target.isize();} 23 | int GetQuery(int i) const {return m_query[i];} 24 | int GetTarget(int i) const {return m_target[i];} 25 | 26 | const svec & Query() const {return m_query;} 27 | const svec & Target() const {return m_target;} 28 | 29 | void Set(int querySize, int targetSize) { 30 | m_query.resize(querySize, 0); 31 | m_target.resize(targetSize, 0); 32 | } 33 | void SetQuery(int i, int v) {m_query[i] = v;} 34 | void SetTarget(int i, int v) {m_target[i] = v;} 35 | 36 | private: 37 | svec m_query; 38 | svec m_target; 39 | }; 40 | 41 | 42 | 43 | 44 | class SeqChunk 45 | { 46 | public: 47 | SeqChunk() { 48 | m_id = -1; 49 | m_ori = 0; 50 | } 51 | 52 | void Set(const string & name, 53 | int start, 54 | int id) { 55 | m_name = name; 56 | m_start = start; 57 | m_id = id; 58 | } 59 | 60 | const string & GetName() const {return m_name;} 61 | int GetStart() const {return m_start;} 62 | int GetID() const {return m_id;} 63 | 64 | void ForceOrientation(int i) {m_ori = i;} 65 | int GetForceOrientation() const {return m_ori;} 66 | 67 | void Print() { 68 | cout << "Sequence " << m_name << " offset " << m_start; 69 | } 70 | 71 | private: 72 | string m_name; 73 | int m_start; 74 | int m_id; 75 | int m_ori; 76 | }; 77 | 78 | class ChunkManager 79 | { 80 | public: 81 | ChunkManager(int size, int overlap) { 82 | m_size = size; 83 | m_overlap = overlap; 84 | } 85 | 86 | int GetCount() const {return m_lengths.isize();} 87 | int GetSize(int i) const {return m_lengths[i];} 88 | 89 | void ChunkIt(vecDNAVector & out, 90 | svec & chunks, 91 | const vecDNAVector & in, 92 | const svec & names, 93 | int nBlocks = 0, 94 | int myBlock = 0, 95 | double line = -1.0) { 96 | 97 | svec selection; 98 | ChunkItSelect(out, chunks, in, names, selection, nBlocks, myBlock, line); 99 | 100 | } 101 | 102 | void ChunkItSelect(vecDNAVector & out, 103 | svec & chunks, 104 | const vecDNAVector & in, 105 | const svec & names, 106 | const svec & selection, 107 | int nBlocks = 0, 108 | int myBlock = 0, 109 | double line = -1.0); 110 | 111 | 112 | 113 | private: 114 | 115 | svec m_lengths; 116 | int m_size; 117 | int m_overlap; 118 | 119 | 120 | }; 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | #endif //SEQCHUNK_H_ 132 | 133 | -------------------------------------------------------------------------------- /tools/src/Cola/runCola.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "base/CommandLineParser.h" 4 | #include "src/Cola/Cola.h" 5 | 6 | 7 | int main(int argc,char** argv) 8 | { 9 | commandArg aStringCmd("-q","query sequence"); 10 | commandArg bStringCmd("-t","target sequence"); 11 | commandArg alignerTypeCmd("-a","Aligner type - Choose 1 : NSGA , 2 : NS , 3 : SWGA, 4 : SW "); 12 | commandArg gapOpenCmd("-o", "Aligner gap open penalty", false); 13 | commandArg mismatchCmd("-m", "Aligner Mismatch penalty", false); 14 | commandArg gapExtCmd("-e", "Aligner gap extension penalty", false); 15 | commandArg selfCmd("-all","all alignments", false); 16 | commandArg maxPCmd("-p","Maximum acceptable P-value", 1.0); 17 | commandArg minIdentCmd("-i","Minium acceptable identity", 0.0); 18 | commandArg bandedCmd("-b", "The bandwidth for banded mode, default is for unbanded", -1); 19 | 20 | commandLineParser P(argc,argv); 21 | P.SetDescription("Aligns two fasta files using Cola"); 22 | P.registerArg(aStringCmd); 23 | P.registerArg(bStringCmd); 24 | P.registerArg(alignerTypeCmd); 25 | P.registerArg(gapOpenCmd); 26 | P.registerArg(mismatchCmd); 27 | P.registerArg(gapExtCmd); 28 | P.registerArg(selfCmd); 29 | P.registerArg(maxPCmd); 30 | P.registerArg(minIdentCmd); 31 | P.registerArg(bandedCmd); 32 | 33 | P.parse(); 34 | 35 | string aString = P.GetStringValueFor(aStringCmd); 36 | string bString = P.GetStringValueFor(bStringCmd); 37 | AlignerType aType = AlignerType(P.GetIntValueFor(alignerTypeCmd)); 38 | int gapOpenPen = P.GetIntValueFor(gapOpenCmd); 39 | int mismatchPen = P.GetIntValueFor(mismatchCmd); 40 | int gapExtPen = P.GetIntValueFor(gapExtCmd); 41 | bool bAll = P.GetBoolValueFor(selfCmd); 42 | double maxP = P.GetDoubleValueFor(maxPCmd); 43 | double minIdent = P.GetDoubleValueFor(minIdentCmd); 44 | int banded = P.GetIntValueFor(bandedCmd); 45 | 46 | vecDNAVector query, target; 47 | 48 | query.Read(aString); 49 | target.Read(bString); 50 | query.RemoveGaps(); 51 | target.RemoveGaps(); 52 | int i, j; 53 | 54 | for (i=0; i=minIdent) { 66 | cout << target.Name(i) << " vs " << query.Name(j) << endl; 67 | cAlgn.print(0,1,cout,100); 68 | } else { 69 | cout<<"No Alignment at given significance threshold"< & Query() const {return m_query;} 26 | const std::vector & Target() const {return m_target;} 27 | 28 | void Set(int querySize, int targetSize) { 29 | m_query.resize(querySize, 0); 30 | m_target.resize(targetSize, 0); 31 | } 32 | void SetQuery(int i, int v) {m_query[i] = v;} 33 | void SetTarget(int i, int v) {m_target[i] = v;} 34 | 35 | private: 36 | std::vector m_query; 37 | std::vector m_target; 38 | }; 39 | 40 | 41 | 42 | 43 | class SeqChunk 44 | { 45 | public: 46 | SeqChunk() { 47 | m_id = -1; 48 | m_ori = 0; 49 | } 50 | 51 | void Set(const string & name, 52 | int start, 53 | int id) { 54 | m_name = name; 55 | m_start = start; 56 | m_id = id; 57 | } 58 | 59 | const string & GetName() const {return m_name;} 60 | int GetStart() const {return m_start;} 61 | int GetID() const {return m_id;} 62 | 63 | void ForceOrientation(int i) {m_ori = i;} 64 | int GetForceOrientation() const {return m_ori;} 65 | 66 | void Print() { 67 | cout << "Sequence " << m_name << " offset " << m_start; 68 | } 69 | 70 | private: 71 | string m_name; 72 | int m_start; 73 | int m_id; 74 | int m_ori; 75 | }; 76 | 77 | class ChunkManager 78 | { 79 | public: 80 | ChunkManager(int size, int overlap) { 81 | m_size = size; 82 | m_overlap = overlap; 83 | } 84 | 85 | int GetCount() const {return m_lengths.size();} 86 | int GetSize(int i) const {return m_lengths[i];} 87 | 88 | void ChunkIt(vecDNAVector & out, 89 | std::vector & chunks, 90 | const vecDNAVector & in, 91 | const std::vector & names, 92 | int nBlocks = 0, 93 | int myBlock = 0, 94 | double line = -1.0) { 95 | 96 | std::vector selection; 97 | ChunkItSelect(out, chunks, in, names, selection, nBlocks, myBlock, line); 98 | 99 | } 100 | 101 | void ChunkItSelect(vecDNAVector & out, 102 | std::vector & chunks, 103 | const vecDNAVector & in, 104 | const std::vector & names, 105 | const std::vector & selection, 106 | int nBlocks = 0, 107 | int myBlock = 0, 108 | double line = -1.0); 109 | 110 | 111 | 112 | private: 113 | 114 | std::vector m_lengths; 115 | int m_size; 116 | int m_overlap; 117 | 118 | 119 | }; 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | #endif //SEQCHUNK_H_ 131 | 132 | -------------------------------------------------------------------------------- /tools/analysis/MultiProtein.h: -------------------------------------------------------------------------------- 1 | #ifndef MULTIPROTEIN 2 | #define MULTIPROTEIN 3 | 4 | #include "analysis/DNAVector.h" 5 | 6 | class CMReadFileStream; 7 | class CMWriteFileStream; 8 | 9 | typedef svec SeqFeature; 10 | 11 | 12 | 13 | class MultiProtein 14 | { 15 | public: 16 | 17 | MultiProtein() { 18 | m_feat.resize(21); 19 | } 20 | MultiProtein(const DNAVector & d) { 21 | m_feat.resize(21); 22 | AddSequence(d); 23 | } 24 | 25 | const DNAVector & Sequence() const {return m_seq;} 26 | 27 | virtual void AddSequence(const DNAVector & d) { 28 | int i, j; 29 | if (m_feat[0].isize() > 0 && d.isize() != m_feat[0].isize()) { 30 | cout << "ERROR: MultiProtein sizes don't match!!" << endl; 31 | throw; 32 | } 33 | if (m_feat[0].isize() == 0) { 34 | for (i=0; i 52 | void TestHelperNormal
::perform_test_accuracy (int &ret_val) 53 | { 54 | const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12 }; 55 | const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); 56 | for (int k = 0; k < nbr_len && ret_val == 0; ++k) 57 | { 58 | const long len = 1L << (len_arr [k]); 59 | FftType fft (len); 60 | ret_val = TestAccuracy ::perform_test_single_object (fft); 61 | } 62 | } 63 | 64 | 65 | 66 | template 67 | void TestHelperNormal
::perform_test_speed (int &ret_val) 68 | { 69 | #if defined (test_settings_SPEED_TEST_ENABLED) 70 | 71 | const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12, 14, 16, 18, 20, 22 }; 72 | const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); 73 | for (int k = 0; k < nbr_len && ret_val == 0; ++k) 74 | { 75 | const long len = 1L << (len_arr [k]); 76 | FftType fft (len); 77 | ret_val = TestSpeed ::perform_test_single_object (fft); 78 | } 79 | 80 | #endif 81 | } 82 | 83 | 84 | 85 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 86 | 87 | 88 | 89 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 90 | 91 | 92 | 93 | #endif // TestHelperNormal_CODEHEADER_INCLUDED 94 | 95 | #undef TestHelperNormal_CURRENT_CODEHEADER 96 | 97 | 98 | 99 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 100 | -------------------------------------------------------------------------------- /tools/extern/RealFFT/TestHelperNormal.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TestHelperNormal.hpp 4 | Copyright (c) 2005 Laurent de Soras 5 | 6 | --- Legal stuff --- 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | *Tab=3***********************************************************************/ 23 | 24 | 25 | 26 | #if defined (TestHelperNormal_CURRENT_CODEHEADER) 27 | #error Recursive inclusion of TestHelperNormal code header. 28 | #endif 29 | #define TestHelperNormal_CURRENT_CODEHEADER 30 | 31 | #if ! defined (TestHelperNormal_CODEHEADER_INCLUDED) 32 | #define TestHelperNormal_CODEHEADER_INCLUDED 33 | 34 | 35 | 36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | #include "test_settings.h" 39 | 40 | #include "TestAccuracy.h" 41 | #if defined (test_settings_SPEED_TEST_ENABLED) 42 | #include "TestSpeed.h" 43 | #endif 44 | 45 | 46 | 47 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 48 | 49 | 50 | 51 | template 52 | void TestHelperNormal
::perform_test_accuracy (int &ret_val) 53 | { 54 | const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12 }; 55 | const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); 56 | for (int k = 0; k < nbr_len && ret_val == 0; ++k) 57 | { 58 | const long len = 1L << (len_arr [k]); 59 | FftType fft (len); 60 | ret_val = TestAccuracy ::perform_test_single_object (fft); 61 | } 62 | } 63 | 64 | 65 | 66 | template 67 | void TestHelperNormal
::perform_test_speed (int &ret_val) 68 | { 69 | #if defined (test_settings_SPEED_TEST_ENABLED) 70 | 71 | const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12, 14, 16, 18, 20, 22 }; 72 | const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); 73 | for (int k = 0; k < nbr_len && ret_val == 0; ++k) 74 | { 75 | const long len = 1L << (len_arr [k]); 76 | FftType fft (len); 77 | ret_val = TestSpeed ::perform_test_single_object (fft); 78 | } 79 | 80 | #endif 81 | } 82 | 83 | 84 | 85 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 86 | 87 | 88 | 89 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 90 | 91 | 92 | 93 | #endif // TestHelperNormal_CODEHEADER_INCLUDED 94 | 95 | #undef TestHelperNormal_CURRENT_CODEHEADER 96 | 97 | 98 | 99 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 100 | --------------------------------------------------------------------------------