Commit 455bf639 by Eric Coissac

Deleted some supurious files

git-svn-id: https://www.grenoble.prabi.fr/svn/LECASofts/ecoPrimers/trunk@227 60f365c0-8329-0410-b2a4-ec073aeeaa1d
parent b625941d
/*
* dinkelbach.cpp
* PHunterLib
*
* Created by Tiayyba Riaz on 6/7/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
//#include <iostream>
//#include <strstream>
//#include <cstring>
#include "nnparams.h"
#include "galign.h"
#include "dinkelbach.h"
void dnkl_initdinkelbach(pdinkelbach dnkl, PNNParams myDiParams, GGAlign mGAlign)
{
dnkl->myDinkParams = myDiParams;
dnkl->myGAlign = mGAlign;
}
int dnkl_iteration(pdinkelbach dnkl, float TempK)
{
int iteration = 0;
nparam_AlterTM(dnkl->myDinkParams, TempK);
float precursor_oldTM = TempK;
float newTM = TempK;
float oldTM = TempK, lambda, oldlambda;
lambda = 999999999999999999.9;
int positive=0;
do
{
iteration++;
galn_InitBorder(dnkl->myGAlign);
galn_CalculateTable(dnkl->myGAlign, 1);
oldlambda=lambda;
lambda =galn_GetFreeEnergyK(dnkl->myGAlign, dnkl->myGAlign->maxloci,dnkl->myGAlign->maxlocj,newTM);
if(lambda < 0.0)
{
if(!positive)
{
//Initial melting temperature greater than expected
newTM = galn_GetEnthalpy(dnkl->myGAlign, dnkl->myGAlign->maxloci,dnkl->myGAlign->maxlocj)/galn_GetEntropy(dnkl->myGAlign, dnkl->myGAlign->maxloci,dnkl->myGAlign->maxlocj)-1;
lambda = oldlambda;
nparam_AlterTM(dnkl->myDinkParams, newTM);
}
else
{
precursor_oldTM = oldTM;
}
}
else
{
positive = 1;
oldTM = newTM;
newTM = galn_GetMeltingTempK(dnkl->myGAlign, dnkl->myGAlign->maxloci,dnkl->myGAlign->maxlocj);
nparam_AlterTM(dnkl->myDinkParams, newTM);
}
}
while(!positive || (newTM - oldTM > 0.001 && (lambda>0.0)&&(lambda<oldlambda)));
if(newTM - oldTM > 0.001 && ((lambda<0.0)||(lambda>oldlambda)))
{
iteration++;
nparam_AlterTM(dnkl->myDinkParams, precursor_oldTM);
galn_InitBorder(dnkl->myGAlign);
galn_CalculateTable(dnkl->myGAlign, 1);
lambda = galn_GetFreeEnergyK(dnkl->myGAlign, dnkl->myGAlign->maxloci,dnkl->myGAlign->maxlocj,precursor_oldTM);
newTM = galn_GetMeltingTempK(dnkl->myGAlign, dnkl->myGAlign->maxloci,dnkl->myGAlign->maxlocj);
nparam_AlterTM(dnkl->myDinkParams, newTM);
}
return iteration;
}
/*
* dinkelbach.h
* PHunterLib
*
* Created by Tiayyba Riaz on 7/2/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
//Module: Achievement of the Dinkelbach algorithm
#ifndef __dinkelbach_h
#define __dinkelbach_h
//#include <iostream>
//#include <strstream>
//#include <cstring>
#include "nnparams.h"
#include "galign.h"
//using namespace std;
//typedef class dinkelbach* DINKEL;
//#pragma GCC visibility push(hidden)
typedef struct dinkelbach_st
{
PNNParams myDinkParams;
GGAlign myGAlign;
}dinkelbach, * pdinkelbach;
//#pragma GCC visibility pop
void dnkl_initdinkelbach(pdinkelbach dnkl, PNNParams, GGAlign);
int dnkl_iteration(pdinkelbach dnkl, float TempK);
#endif /* __dinkelbach_h */
/*
* galign.h
* PHunterLib
*
* Created by Tiayyba Riaz on 7/2/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
//=============================================================================
// Module: galign.h
// Project: Cubic Project - Calculation of melting temperature and free
// energy of two DNA strands
// Type: header file - Thermodynamic Alignment.
// Language: c++
// Compiler: microsoft visual c++ 6.0, unix/linux gcc
// System/OS: Windows 32, Sun solaris, Linux, other unix systems (untested)
// Database: none
// Description: class GAlign - Thermodynamic Alignment Algorithm
// Author: leber
// Date: 01/2002 - 02/2002
// Copyright: (c) L. Kaderali & M. Leber, 01/2002 - 02/2002
//
// Revision History
// $ 00sep04 LK : created
// $ 00dec30 LK : changed to do local alignment of probe against
// one entire sequence
// $ 01feb07 LK : optimized
// #$
//=============================================================================
#if !defined(AFX_GAlign_H__1B9227F7_82AB_11D4_9FFF_000000000000__INCLUDED_)
#define AFX_GAlign_H__1B9227F7_82AB_11D4_9FFF_000000000000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//#include <iostream>
//#include <strstream>
//#include <ostream>
#include "nnparams.h" // Nearest Neighbor Parameters
//#include "../gsfxtree/gsfxtree.h" // Suffix Tree Stuff
//using namespace std;
#ifdef _pack
#pragma pack(1)
#endif
//-----------------------------------------------------------------------------
// class GAlign
//#pragma GCC visibility push(hidden)
//typedef class GAlign* GGAlign;
typedef struct GAlign_st
{
//public:
// lk01feb07: removed maxlocstuff as not requiered by thermtreealign...
float maxlocg; // maximum local dG value found
int maxloci; // i position thereof
int maxlocj; // j position thereof
int maxloct; // and type of maximum alignment!
int targetNumber; // id number of target sequence
// PGSfxLeaf probeNode; // identifier for probe sequence
//private:
char *seq1; // Sequence 1
char *seq2; // Sequence 2
int seq1len; // Length of Sequence 1
int seq2len; // Length of Sequence 2
int maxseq1len; // length of longest target...
float *dH; // Dynamic Programming Table for Entropy
float *dS; // Dynamic Programming Table for Enthalpy
PNNParams GNNParams; // Nearest Neighbor parameters
// float forbidden_entropy;
}GAlign, * GGAlign;
void galn_initGAlign(GGAlign galn, int, int, PNNParams);
void galn_finiGAlign(GGAlign galn);
//void galn_InitStrings(GGAlign galn, char*,char*,int,int,int=0);
void galn_InitStrings(GGAlign galn, char*,char*,int,int,int);
void galn_InitBorder(GGAlign galn);
//void galn_CalculateTable(GGAlign galn, int=1);
void galn_CalculateTable(GGAlign galn, int);
float galn_GetEntropy(GGAlign galn, int, int);
float galn_GetEnthalpy(GGAlign galn, int, int);
float galn_GetFreeEnergyK(GGAlign galn, int, int, float);
float galn_GetFreeEnergyC(GGAlign galn, int, int, float);
float galn_GetMeltingTempC(GGAlign galn, int, int);
float galn_GetMeltingTempK(GGAlign galn, int, int);
void galn_printEnthalpyTable(GGAlign galn, int level);
void galn_printEntropyTable(GGAlign galn, int level);
//#pragma GCC visibility pop
#endif //!defined(AFX_GAlign_H__1B9227F7_82AB_11D4_9FFF_000000000000__INCLUDED_)
/*
* PHunterLib.cp
* PHunterLib
*
* Created by Tiayyba Riaz on 6/7/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#include <stdlib.h>
#include "libthermo.h"
#include "nnparams.h"
#include "thermalign.h"
#include "galign.h"
#include "dinkelbach.h"
//#define EXPORT __attribute__((visibility("default")))
//char targetsFile [1000]="";
//char nonTargetsFile [1000]="";
//char primersFile [1000]="";
//char primersOutputFile [1000]="";
//int minLength = DEF_MIN_PRIMER_LENGTH;
//int maxLength = DEF_MAX_PRIMER_LENGTH;
//int productMinLength = DEF_MIN_PROD_LENGTH;
//int productMaxLength = DEF_MAX_PROD_LENGTH;
//char forwardPrimer [PRIMERS_MAX_SIZE] = DEF_FORWARD_PRIMER;
//char reversePrimer [PRIMERS_MAX_SIZE] = DEF_REVERSE_PRIMER;
//int beginPosForward = DEF_BEGINPOS_FORWARD;
//int endPosForward = DEF_ENDPOS_FORWARD;
//int beginPosReverse = DEF_BEGINPOS_REVERSE;
//int endPosReverse = DEF_ENDPOS_REVERSE;
//char maskTargets [PRIMERS_MAX_SIZE] = DEF_MASK_TARGETS;
//char maskNonTargets [PRIMERS_MAX_SIZE] = DEF_MASK_NONTARGETS;
//char degeneracy[PRIMERS_MAX_SIZE]=DEF_DEGENERACY;
//int nseqForCandidates = DEF_SEQ_FOR_CANDS;
//float minCoverageTargets = DEF_MIN_COVERAGE_TARGETS;
//float maxCoverageNonTargets = DEF_MAX_COVERAGE_NONTARGETS;
//float maxSelfScore = DEF_MAX_SELF_SCORE;
//float maxEndScore = DEF_MAX_END_SCORE;
//float minGCContent = DEF_MIN_GCCONTENT;
//float maxGCContent = DEF_MAX_GCCONTENT;
//int gcClamp = DEF_GCCLAMP;
//int maxPolyX = DEF_MAX_POLY_X;
float concPrimers = DEF_CONC_PRIMERS;
float concSequences = DEF_CONC_SEQUENCES;
float salt = DEF_SALT;
int salMethod = SALT_METHOD_SANTALUCIA;
//float minTempTargets=DEF_MIN_TEMP_TARGETS;
//float maxTempTargets=DEF_MAX_TEMP_TARGETS;
//float maxTempNonTargets=DEF_MAX_TEMP_NONTARGETS;
//float deltaTempNonTargets=DEF_DELTA_TEMP_NONTARGETS;
//float maxPairTempDiff=DEF_MAX_PAIR_TEMP_DIFF;
//char primersLabel [1000] = DEF_PRIMERS_LABEL;
//int fullStats = DEF_FULL_STATS;
//char seqRank [10000] = DEF_SEQ_RANK;
int countGCContent(char * seq ) {
int lseq = strlen(seq);
int k;
int count = 0;
for( k=0;k<lseq;k++) {
if (seq[k] == 'G' || seq[k] == 'C' ) {
count+=1;
}
}
return count;
}
char getComplement(char base) {
if(base == 'A') return 'T';
else if(base == 'G') return 'C';
else if(base == 'C') return 'G';
else if(base == 'T') return 'A';
else if(base == 'N') return 'N';
return 'A';
}
void addDollarSigns(char * seq) {
int n = strlen(seq);
int i;
seq[n+2]=0;
seq[n+1]='$';
for( i=n;i>0;i--) {
seq[i]=seq[i-1];
}
seq[0] = '$';
}
void removeDollarSigns(char * seq) {
int n = strlen(seq);
int i;
for( i=0;i<n-2;i++) {
seq[i]=seq[i+1];
}
seq[n-2]=0;
}
float calculateMeltingTemperatureInt (char * seq1, char * seq2, PNNParams params) {
int length = strlen(seq2);
int perfectComplements = 1;
int k;
if(strlen(seq1)!= length) {
perfectComplements = 0;
}
for( k=0;k<length && perfectComplements;k++) {
if(seq2[k] != getComplement(seq1[k])) {
perfectComplements = 0;
}
}
addDollarSigns(seq1);
addDollarSigns(seq2);
CThermAlign myAlignment;//(strlen(seq1),strlen(seq2),params);
therm_initCThermAlign(&myAlignment, strlen(seq1),strlen(seq2),params);
therm_InitStrings (&myAlignment, seq1,seq2,strlen(seq1),strlen(seq2), 0);
therm_InitBorder(&myAlignment);
therm_CalculateTable(&myAlignment, 1);
float answer;
if(perfectComplements) {
answer = therm_GetMeltingTempC(&myAlignment, myAlignment.maxloci,myAlignment.maxlocj);
} else {
float tempK = therm_GetMeltingTempK (&myAlignment, myAlignment.maxloci,myAlignment.maxlocj);
GAlign mydGAlign;//(strlen(seq1),strlen(seq2),params);
galn_initGAlign(&mydGAlign, strlen(seq1),strlen(seq2),params);
galn_InitStrings(&mydGAlign, seq1,seq2,strlen(seq1),strlen(seq2), 0);
dinkelbach myDinkel;//(params, &mydGAlign);
dnkl_initdinkelbach(&myDinkel, params, &mydGAlign);
dnkl_iteration(&myDinkel, tempK);
answer = galn_GetMeltingTempC(&mydGAlign, mydGAlign.maxloci,mydGAlign.maxlocj);
galn_finiGAlign(&mydGAlign);
}
removeDollarSigns(seq1);
removeDollarSigns(seq2);
therm_finiCThermAlign(&myAlignment);
return answer;
}
float calculateMeltingTemperature (char * seq1, char * seq2) {
long len = strlen (seq1);
char *seq1new = (char *) calloc(len + 3, sizeof(char));//new char[len + 3];
len = strlen (seq2);
char *seq2new = (char *) calloc(len + 3, sizeof(char));//new char[len + 3];
strcpy (seq1new, seq1);
strcpy (seq2new, seq2);
PNNParams paramsPrimerSeq = (PNNParams) calloc (1, sizeof(CNNParams));
nparam_InitParams(paramsPrimerSeq, concPrimers,concSequences,salt,salMethod);
float temp = calculateMeltingTemperatureInt(seq1new, seq2new, paramsPrimerSeq);
free (seq1new);
free (seq2new);
return temp;
}
float calculateMeltingTemperatureBasic (char * seq) {
int gccount;
float temp;
int seqlen;
seqlen = strlen (seq);
gccount = countGCContent (seq);
temp = 64.9 + 41*(gccount - 16.4)/seqlen;
return temp;
}
/*
* PHunterLib.h
* PHunterLib
*
* Created by Tiayyba Riaz on 7/2/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#ifndef PHunterLib_
#define PHunterLib_
#define TARGETS_MAX_SIZE 2000
#define NON_TARGETS_MAX_SIZE 10000
#define SEQUENCES_MAX_SIZE 100000
#define PRIMERS_MAX_SIZE 100
#define CANDIDATES_MAX_SIZE 100000
#define SEEDS_MAX_SIZE 9
#define SEEDSTABLE_TAM 1000000
#define MAX_DEGENERACY 256
#define STAT_COUNTS 12
#define STAT_TOTAL_CANDIDATES 0
#define STAT_TEST_DEGENERACY 1
#define STAT_TEST_GCCONTENT 2
#define STAT_TEST_GCCLAMP 3
#define STAT_TEST_MAX_POLY_X 4
#define STAT_TEST_SELFCOMP 5
#define STAT_TEST_TMSELF 6
#define STAT_TEST_TARGETS 7
#define STAT_TEST_NONTARGETS 8
#define STAT_ALLTESTS 9
#define STAT_FAILED_SELFCOMP_LOW 10
#define STAT_FAILED_SELFCOMP_HIGH 11
#define DEF_MIN_PRIMER_LENGTH 20
#define DEF_MAX_PRIMER_LENGTH 25
#define DEF_MIN_PROD_LENGTH 75
#define DEF_MAX_PROD_LENGTH 200
#define DEF_FORWARD_PRIMER "NONE"
#define DEF_REVERSE_PRIMER "NONE"
#define DEF_BEGINPOS_FORWARD 0
#define DEF_ENDPOS_FORWARD SEQUENCES_MAX_SIZE
#define DEF_BEGINPOS_REVERSE 0
#define DEF_ENDPOS_REVERSE SEQUENCES_MAX_SIZE
#define DEF_MASK_TARGETS "11"
#define DEF_MASK_NONTARGETS "NONE"
#define DEF_DEGENERACY "1"
#define DEF_SEQ_FOR_CANDS 1
#define DEF_MIN_COVERAGE_TARGETS 100
#define DEF_MAX_COVERAGE_NONTARGETS 0
#define DEF_MAX_SELF_SCORE 800
#define DEF_MAX_END_SCORE 300
#define DEF_MIN_GCCONTENT 25
#define DEF_MAX_GCCONTENT 75
#define DEF_GCCLAMP 0
#define DEF_MAX_POLY_X 5
#define DEF_CONC_PRIMERS 0.0000008
#define DEF_CONC_SEQUENCES 0
#define DEF_SALT 0.05
#define DEF_MIN_TEMP_TARGETS 40
#define DEF_MAX_TEMP_TARGETS 70
#define DEF_MAX_TEMP_NONTARGETS 40
#define DEF_DELTA_TEMP_NONTARGETS 0
#define DEF_MAX_PAIR_TEMP_DIFF 40
#define DEF_PRIMERS_LABEL "P"
#define DEF_FULL_STATS 0
#define DEF_SEQ_RANK "NONE"
float calculateMeltingTemperature (char * seq1, char * seq2);
float calculateMeltingTemperatureBasic (char * seq);
int countGCContent(char * seq );
#endif
//=============================================================================
// Module: thermalign.h
// Project: Diploma Thesis - Probe Selection for DNA Microarrays
// Type: header file - Thermodynamic Alignment.
// Language: c++
// Compiler: microsoft visual c++ 6.0, unix/linux gcc
// System/OS: Windows 32, Sun solaris, Linux, other unix systems (untested)
// Database: none
// Description: class CThermAlign - Thermodynamic Alignment Algorithm
// Author: kaderali
// Date: 9/2000 - 12/2000
// Copyright: (c) L. Kaderali, 9/2000 - 12/2000
//
// Revision History
// $ 00sep04 LK : created
// $ 00dec30 LK : changed to do local alignment of probe against
// one entire sequence
// $ 01feb07 LK : optimized
// #$
//=============================================================================
#if !defined(AFX_THERMALIGN_H__1B9227F7_82AB_11D4_9FFF_000000000000__INCLUDED_)
#define AFX_THERMALIGN_H__1B9227F7_82AB_11D4_9FFF_000000000000__INCLUDED_
//#if _MSC_VER > 1000
//#pragma once
//#endif // _MSC_VER > 1000
//#include <iostream>
//#include <strstream>
//#include <ostream>
#include "nnparams.h" // Nearest Neighbor Parameters
//#include "../gsfxtree/gsfxtree.h" // Suffix Tree Stuff
//using namespace std;
//#ifdef _pack
//#pragma pack(1)
//#endif
//-----------------------------------------------------------------------------
// class CThermAlign
//#pragma GCC visibility push(hidden)
//typedef class CThermAlign* PThermAlign;
typedef struct CThermAlign_t
{
//public:
#ifdef _output_alignment
/* void printAlignment(ostream &outputStream);
void OutputAlignment(ostream &outputStream);
bool OutputAlignment(ostream &outputStream, int, int, int, bool local=false);
void OutputLocalAlignment(ostream &outputStream);
void PrintDPTable(ostream&);*/
#endif
// lk01feb07: removed maxlocstuff as not requiered by thermtreealign...
float maxloctm; // maximum local temperature found
int maxloci; // i position thereof
int maxlocj; // j position thereof
int maxloct; // and type of maximum alignment!
int targetNumber; // id number of target sequence
// PGSfxLeaf probeNode; // identifier for probe sequence
char *seq1; // Sequence 1
char *seq2; // Sequence 2
int seq1len; // Length of Sequence 1
int seq2len; // Length of Sequence 2
int maxseq1len; // length of longest target...
//private:
float *dH; // Dynamic Programming Table for Entropy
float *dS; // Dynamic Programming Table for Enthalpy
PNNParams NNParams; // Nearest Neighbor parameters
// float forbidden_entropy;
#ifdef _output_alignment
//ostrstream *s1aptr, *s2aptr, *atypptr;
// Used to buffer aligned sequences (on output)
//ostrstream s1align;
//ostrstream s2align;
//ostrstream aligntype; // insert, deletion, match, unmatch (for output)
// same for local alignment:
/* removed lk00jan08: use global instead!
ostrstream ls1align;
ostrstream ls2align;
ostrstream laligntype; // insert, deletion, match, unmatch (for output)
*/
#endif
}CThermAlign, * PThermAlign;
//#pragma GCC visibility pop
float therm_GetEntropy(PThermAlign thrma, int, int);
float therm_GetEnthalpy(PThermAlign thrma, int, int);
float therm_GetFreeEnergy(PThermAlign thrma, int, int);
float therm_GetFreeEnergyK(PThermAlign thrma, int, int, float);
float therm_GetFreeEnergyC(PThermAlign thrma, int, int, float);
float therm_GetMeltingTempC(PThermAlign thrma, int, int);
float therm_GetMeltingTempK(PThermAlign thrma, int, int);
void therm_initCThermAlign(PThermAlign thrma, int, int, PNNParams);
void therm_finiCThermAlign(PThermAlign thrma);
//void therm_InitStrings(PThermAlign thrma, char*,char*,int,int,int=0);
void therm_InitStrings(PThermAlign thrma, char*,char*,int,int,int);
void therm_InitBorder(PThermAlign thrma);
//void therm_CalculateTable(PThermAlign thrma, int=1);
void therm_CalculateTable(PThermAlign thrma, int);
#endif // !defined(AFX_THERMALIGN_H__1B9227F7_82AB_11D4_9FFF_000000000000__INCLUDED_)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment