Skip to content

Commit fd18b78

Browse files
committed
clean up code
1 parent 2d43036 commit fd18b78

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

component/src/main/java/org/cbioportal/genome_nexus/component/annotation/HugoGeneSymbolResolver.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ public String resolve(TranscriptConsequence transcriptConsequence)
3030
}
3131

3232
String symbol = transcriptConsequence.getGeneSymbol();
33-
if (symbol == null || symbol.trim().isEmpty()) {
33+
if (symbol == null || symbol.isEmpty()) {
3434
return null;
3535
}
3636

3737
String hgncId = transcriptConsequence.getHgncId();
38-
if (hgncId != null && !hgncId.trim().isEmpty()) {
39-
String mapped = ensemblRepository.getOfficialHugoSymbol(symbol, hgncId);
40-
return mapped;
38+
if (hgncId != null && !hgncId.isEmpty()) {
39+
return ensemblRepository.getOfficialHugoSymbol(symbol, hgncId);
4140
}
4241
return ensemblRepository.getOfficialHugoSymbol(symbol);
4342
}

component/src/main/java/org/cbioportal/genome_nexus/component/annotation/IndexBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Index buildIndex(VariantAnnotation variantAnnotation)
3232
{
3333
Index index = new Index();
3434
index.setVariant(this.resolveVariant(variantAnnotation));
35-
List<String> hugoSymbols;
35+
List<String> hugoSymbols;
3636
if (Boolean.TRUE.equals(this.replaceOldGeneSymbol)) {
3737
hugoSymbols = this.hugoGeneSymbolResolver.resolveAllHugoGeneSymbols(variantAnnotation);
3838
} else {
@@ -74,7 +74,7 @@ private List<String> resolveAllOriginalGeneSymbols(VariantAnnotation variantAnno
7474
Set<String> hugoSymbolSet = new HashSet<>();
7575

7676
for (TranscriptConsequence tc : variantAnnotation.getTranscriptConsequences()) {
77-
if (tc.getGeneSymbol() != null && !tc.getGeneSymbol().trim().isEmpty()) {
77+
if (tc.getGeneSymbol() != null && !tc.getGeneSymbol().isEmpty()) {
7878
hugoSymbolSet.add(tc.getGeneSymbol());
7979
}
8080
}

persistence/src/main/java/org/cbioportal/genome_nexus/persistence/internal/EnsemblRepositoryImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,21 @@ public String findEntrezGeneIdByHugoSymbol(String hugoSymbol) {
215215

216216
@Override
217217
public List<String> findEntrezGeneIdByHugoSymbol(String hugoSymbol, Boolean searchInAliases) {
218-
List<String> results = new ArrayList<>();
219-
String direct = hugoSymbolToEntrezGeneIdMap.get(hugoSymbol);
220-
if (direct != null && !results.contains(direct)) {
221-
results.add(direct);
218+
List<String> entrezGeneIds = new ArrayList<>();
219+
String entrezGeneId = hugoSymbolToEntrezGeneIdMap.get(hugoSymbol);
220+
if (entrezGeneId != null && !entrezGeneIds.contains(entrezGeneId)) {
221+
entrezGeneIds.add(entrezGeneId);
222222
}
223223

224224
if (Boolean.TRUE.equals(searchInAliases)) {
225225
List<String> aliasMatches = geneAliasToEntrezGeneIdMap.get(hugoSymbol);
226226
if (aliasMatches != null) {
227227
for (String id : aliasMatches) {
228-
if (id != null && !results.contains(id)) results.add(id);
228+
if (id != null && !entrezGeneIds.contains(id)) entrezGeneIds.add(id);
229229
}
230230
}
231231
}
232-
return results;
232+
return entrezGeneIds;
233233
}
234234

235235
@Override

web/src/main/resources/application.properties.EXAMPLE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ prioritize_cancer_gene_transcripts=true
7474
cache.enabled=true
7575

7676
# replace old HGNC gene symbol to the latest HGNC gene symbol in annotationSummary - transcriptConsequenceSummary
77-
replace_old_hgnc_gene_symbol=true
77+
replace_old_hgnc_gene_symbol=true

web/src/test/java/org/cbioportal/genome_nexus/web/NucleotideContextIntegrationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package org.cbioportal.genome_nexus.web;
22

33
import org.cbioportal.genome_nexus.model.NucleotideContext;
4+
import static org.junit.Assert.assertEquals;
45
import org.junit.Test;
56
import org.junit.runner.RunWith;
67
import org.springframework.boot.test.context.SpringBootTest;
78
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
89
import org.springframework.web.client.RestTemplate;
910

10-
import static org.junit.Assert.assertEquals;
11-
1211
@RunWith(SpringJUnit4ClassRunner.class)
1312
@SpringBootTest(
1413
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,

0 commit comments

Comments
 (0)