-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'p2rank-2-4' into develop
- Loading branch information
Showing
7 changed files
with
78 additions
and
16 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
50 changes: 50 additions & 0 deletions
50
src/main/groovy/cz/siret/prank/domain/labeling/ColumnBasedResidueLabeler.groovy
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,50 @@ | ||
package cz.siret.prank.domain.labeling | ||
|
||
import cz.siret.prank.domain.Dataset | ||
import cz.siret.prank.domain.Protein | ||
import cz.siret.prank.domain.Residue | ||
import cz.siret.prank.domain.Residues | ||
import cz.siret.prank.utils.Sutils | ||
import cz.siret.prank.utils.Writable | ||
import groovy.transform.CompileStatic | ||
import groovy.util.logging.Slf4j | ||
|
||
/** | ||
* | ||
*/ | ||
@Slf4j | ||
@CompileStatic | ||
class ColumnBasedResidueLabeler extends ResidueLabeler<Boolean> implements Writable { | ||
|
||
@Override | ||
ResidueLabeling<Boolean> labelResidues(Residues residues, Protein protein, Dataset.Item item) { | ||
|
||
Set<String> positives = Sutils.split(item.columnValues.get(Dataset.COLUMN_POSITIVE_RESIDUES), ',').toSet() | ||
|
||
return createLabelingFromPositiveResidueCodes(residues, positives) | ||
} | ||
|
||
@Override | ||
boolean isBinary() { | ||
return true | ||
} | ||
|
||
@Override | ||
ResidueLabeling<Double> getDoubleLabeling() { | ||
return null | ||
} | ||
|
||
//===========================================================================================================// | ||
|
||
static ResidueLabeling<Boolean> createLabelingFromPositiveResidueCodes(Residues residues, Set<String> positives) { | ||
ResidueLabeling<Boolean> labeling = new ResidueLabeling<Boolean>() | ||
|
||
for (Residue residue : residues) { | ||
boolean label = positives.contains(residue.toString()) | ||
labeling.add(residue, label) | ||
} | ||
|
||
return labeling | ||
} | ||
|
||
} |
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
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