-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Genet Abay
committed
Feb 26, 2018
1 parent
717aa17
commit d5fcd22
Showing
11 changed files
with
570 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/com/compomics/coss/Controller/Validation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package com.compomics.coss.Controller; | ||
|
||
import com.compomics.coss.Model.ComparisonResult; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author Genet | ||
*/ | ||
public class Validation { | ||
|
||
public Validation() { | ||
|
||
} | ||
|
||
public void compareNmerge(List<ArrayList<ComparisonResult>> targetResult, List<ArrayList<ComparisonResult>> decoyResult) { | ||
|
||
List<ArrayList<ComparisonResult>> validatedResult = null; | ||
//calculate FDR=Ndecoy/Ntargethits | ||
|
||
int c = 0; | ||
int decoySSM = 0; | ||
|
||
for (ArrayList<ComparisonResult> rTarget : targetResult) { | ||
ArrayList<ComparisonResult> rDecoy = decoyResult.get(c++); | ||
if (rTarget.get(0).compareTo(rDecoy.get(0)) < 0) { | ||
|
||
rTarget.clear(); | ||
rTarget.addAll(rDecoy); | ||
decoySSM++; | ||
|
||
} | ||
|
||
} | ||
Collections.sort(targetResult, (ArrayList<ComparisonResult> o1, ArrayList<ComparisonResult> o2) -> Double.valueOf(o1.get(0).getScore()).compareTo(o2.get(0).getScore())); | ||
|
||
} | ||
|
||
public int validate(List<ArrayList<ComparisonResult>> result, double threshold) { | ||
|
||
int cutoff_index = 0; | ||
int numDecoy = 0; | ||
int numTarget = 0; | ||
double fdr = 0; | ||
//double threshold = 0.01; | ||
|
||
for (ArrayList<ComparisonResult> r : result) { | ||
// ArrayList<ComparisonResult> rDecoy=decoyResult.get(c++); | ||
if (r.get(0).getResultType().equals("target")) { | ||
|
||
numTarget++; | ||
|
||
} else { | ||
numDecoy++; | ||
} | ||
|
||
fdr = numDecoy / (double) numTarget; | ||
|
||
if (fdr >= threshold) { | ||
break; | ||
} | ||
cutoff_index++; | ||
|
||
} | ||
if(cutoff_index==0) | ||
cutoff_index=result.size(); | ||
return cutoff_index; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.