Skip to content

Commit 7ed9616

Browse files
committed
Use better string distance method for comparing file names when scanning
for data sets.
1 parent a3522a2 commit 7ed9616

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/resolver/DataSetResolver.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import java.util.HashMap;
1515
import java.util.HashSet;
1616
import java.util.List;
17-
import java.util.Locale;
1817
import java.util.Map;
1918
import java.util.Optional;
2019
import java.util.Set;
@@ -115,14 +114,14 @@ private static List<DataSetParameters> createDataSets(Map<Type,List<Path>> types
115114

116115
// MKTODO what about other enrichment types?
117116
for(Path enrichment : types.get(Type.ENRICHMENT_GENERIC)) {
118-
DataSetFiles files = new DataSetFiles();
119-
files.setEnrichmentFileName1(enrichment.toAbsolutePath().toString());
120-
121117
Optional<Path> closestExpr = findClosestMatch(enrichment, exprFiles);
122118
Optional<Path> closestRanks = findClosestMatch(enrichment, rankFiles);
123119
Optional<Path> closestClass = findClosestMatch(enrichment, clasFiles);
124120
Optional<Path> closestGmt = findClosestMatch(enrichment, gmtFiles);
125121

122+
DataSetFiles files = new DataSetFiles();
123+
files.setEnrichmentFileName1(enrichment.toAbsolutePath().toString());
124+
126125
closestExpr.ifPresent(path -> {
127126
exprFiles.remove(path);
128127
files.setExpressionFileName(path.toAbsolutePath().toString());
@@ -151,10 +150,10 @@ private static List<DataSetParameters> createDataSets(Map<Type,List<Path>> types
151150
private static Optional<Path> findClosestMatch(Path p, List<Path> candidates) {
152151
String pf = p.getFileName().toString();
153152

154-
Map<Path,Integer> scores = new HashMap<>();
153+
Map<Path,Double> scores = new HashMap<>();
155154
for(Path candidate : candidates) {
156155
String filename = candidate.getFileName().toString();
157-
int score1 = StringUtils.getFuzzyDistance(pf, filename, Locale.getDefault());
156+
double score1 = StringUtils.getJaroWinklerDistance(pf, filename);
158157
scores.put(candidate, score1);
159158
}
160159

0 commit comments

Comments
 (0)