* system of Palma. Otherwiese scoring_functions should point to an array of
* plifs scoring the respective pairs of characters together with the EST
* quality score.
- *
- *
*/
-double getScore(double *matchmatrix,int mlen, int dnaChar, int estChar, struct penalty_struct *scoring_functions) {
- double score = 0.0;
+double scoreMatch(int dnaChar, int estChar, double baseScore){
+ for(int idx=0;idx<24;idx++)
+ struct penalty_struct currentPen = ::qualityScores[idx];
- if( scoring_functions == 0 ) {
- if( estChar == -1 )
- score = matchmatrix[mlen*dnaChar];
+ return 1.0;
+}
- if( dnaChar == -1 )
- score = matchmatrix[estChar];
+double getScore(double *matchmatrix,int mlen, int dnaChar, int estChar, double baseScore, mode scoringScheme) {
+ double score = 0.0;
- if( estChar != -1 && dnaChar != -1 )
- score = matchmatrix[mlen* dnaChar +estChar];
- } else {
+ if( scoringScheme == NORMAL ) {
if( estChar == -1 )
score = matchmatrix[mlen*dnaChar];
score = matchmatrix[estChar];
if( estChar != -1 && dnaChar != -1 )
- //scoring_functions
score = matchmatrix[mlen* dnaChar +estChar];
+ } else {
+ score = scoreMatch(dnaChar,estChar,baseScore);
}
return score;
/*********************************************************************************************/
const int mlen = 6; // length of matchmatrix
int estChar, dnaChar; // 0:'-', 1:'a', 2:'c', 3:'g', 4:'t', 5:'n'
+
+
+ double baseScore;
+ double *est_scores = new double[est_len];
+ for(int i=0;i<est_len;i++)
+ est_scores[i] = 0.0;
+
+ mode currentMode = NORMAL;
+
+
double prevValue ;
double tempValue;
int max_len = (int)functions->limits[functions->len-1] ; //last (len) supporting point of h
{
dnaChar = check_char(dna[j-1]) ; // -1 because of of the gaps in the 0.line/column of the al-matrix
estChar = check_char(est[i-1]) ;
+ baseScore = est_scores[i-1];
//if introns of length greater than max_len possible
if (isfinite(prevValue))
{
// tempValue = prevValue +(matchmatrix[mlen* dnaChar]); /* score(gap,DNA) */
- tempValue = prevValue + getScore(matchmatrix,mlen,dnaChar,-1,scoring_functions);
+ tempValue = prevValue + getScore(matchmatrix,mlen,dnaChar,-1,baseScore,currentMode);
if (isfinite(tempValue))
{
assert(num_elem<max_num_elem) ;
if (isfinite(prevValue))
{
//tempValue = prevValue +(matchmatrix[mlen* dnaChar +estChar]);//DNA mit EST
- tempValue = prevValue + getScore(matchmatrix,mlen,dnaChar,estChar,scoring_functions);
+ tempValue = prevValue + getScore(matchmatrix,mlen,dnaChar,estChar,baseScore,currentMode);
if (isfinite(tempValue))
{
assert(num_elem<max_num_elem) ;
if (isfinite(prevValue))
{
// tempValue = prevValue +(matchmatrix[estChar]); /* score(EST,gap) */
- tempValue = prevValue + getScore(matchmatrix,mlen,-1,estChar,scoring_functions);
+ tempValue = prevValue + getScore(matchmatrix,mlen,-1,estChar,baseScore,currentMode);
if (isfinite(tempValue))
{
assert(num_elem<max_num_elem) ;
double getScore(double *matchmatrix,int mlen, int dnaChar, int estChar);
+enum mode { NORMAL, USE_QUALITY_SCORES};
+
+double scoreMatch(int dnaChar, int estChar, double baseScore);
+
+
#endif // _FILLMATRIX_H__
delete[] PEN ;
}
+void copy_penalty_struct(struct penalty_struct *old, struct penalty_struct *newp) {
+ newp->len = old->len;
+ newp->limits = old->limits;
+ newp->penalties = old->penalties;
+ newp->max_len = old->max_len;
+ newp->min_len = old->min_len;
+ newp->cache = old->cache;
+ newp->transform = old->transform;
+ newp->id = old->id;
+ newp->next_pen = old->next_pen;
+ newp->name = old->name;
+ newp->use_svm = old->use_svm;
+}
+
//struct penalty_struct * read_penalty_struct_from_cell(const mxArray * mx_penalty_info, int &P)
//{
void init_penalty_struct(struct penalty_struct &PEN) ;
void delete_penalty_struct_palma(struct penalty_struct &PEN) ;
//void delete_penalty_struct_array(struct penalty_struct *PEN, INT len) ;
+void copy_penalty_struct(struct penalty_struct *old, struct penalty_struct *newp);
//#ifdef HAVE_MATLAB
//struct penalty_struct * read_penalty_struct_from_cell(const mxArray * mx_penalty_info, mwSize &P) ;
REAL lookup_penalty(const struct penalty_struct *PEN, INT p_value,
REAL* svm_values, bool follow_next=true) ;
+extern struct penalty_struct *qualityScores;
+
#endif
myalign([nr_paths], dna, est, {h}, matchmatrix, donor, acceptor, remove_duplicate_scores, ...
print_matrix) */
+struct penalty_struct *qualityScores = 0;
+
Alignment::Alignment() {
len = 0;
limits = 0;
mmatrix_param = 0;
alignmentscores = 0;
qualityMatrix = 0;
- matching_plifs = 0;
+
+ ::qualityScores = new struct penalty_struct[24];
}
void Alignment::setQualityMatrix(double* qMat, int length){
qualityMatrix[i] = qMat[i];
}
-void Alignment::setMatchPlifs(struct penalty_struct* match_plifs) {
- matching_plifs = new struct penalty_struct[10];
- for(int i=0; i<24; i++)
- matching_plifs[i] = match_plifs[i];
+void Alignment::setMatchPlifs(struct penalty_struct match_plifs, int idx) {
+ struct penalty_struct *currentPlif = new struct penalty_struct();
+ copy_penalty_struct(&match_plifs,currentPlif);
+ ::qualityScores[idx] = (*currentPlif);
}
void Alignment::getDNAEST(){}
char dna_char;
};
-
void fill_matrix (int nr_paths, Pre_score* matrices[], int len_est, int len_dna, char* est, char* dna, penalty_struct* functions, double* matchmatrix, double* donor, double* acceptor, bool remove_duplicate_scores, int nr_donor_sites, int* donor_sites, int* max_score_positions);
int check_char(char base);
double* donor, int d_len, double* acceptor, int a_len,
bool remove_duplicate_scores, bool print_matrix);
- void setMatchPlifs(struct penalty_struct* match_plifs);
+ void setMatchPlifs(struct penalty_struct match_plifs,int idx);
void penSetLength(int l) { len = l; }
void penSetLimits(REAL* lts) {
-def initializeQualityScoringFunctions(numPlifs,numSuppPoints):
+def initializeQualityScoringFunctions(alignment,numPlifs,numSuppPoints):
- allPlifs = [0]*numPlifs
+ min_intron_len=20
+ max_intron_len=1000
+ min_svm_score=-5
+ max_svm_score=5
for idx in range(numPlifs):
curPlif.use_svm = 0
curPlif.next_id = 0
- allPlifs[idx] = d
-
- return allPlifs
+ curPlif = curPlif.convert2SWIG()
+ alignment.setMatchPlifs(curPlif,idx)
class QPalma:
numPlifs = 24
numSuppPoints = 30
- allMatchingPlifs = initializeQualityScoringFunctions(numPlifs,numSuppPoints)
- # self.numQualSuppPoints
#############################################################################################
# Training
qualityMat = QPalmaDP.createDoubleArrayFromList(qualityMatrix)
currentAlignment.setQualityMatrix(qualityMat,self.numQualSuppPoints)
- currentAlignment.setMatchPlifs()
+ initializeQualityScoringFunctions(currentAlignment,numPlifs,numSuppPoints)
#print 'PYTHON: Calling myalign...'
# calculates SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest