Skip to content

Commit

Permalink
fixed "all" database label bug in cli. fixes #92
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleisch committed Jan 10, 2023
1 parent e3e0c73 commit 887c96d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class DataSourceCandidates implements Iterable<String> {
DataSource.values()).filter(it -> it != DataSource.TRAIN).map(DataSource::name)
.collect(Collectors.toList()));

public static final String VALID_DATA_STRING = "Example: possible DBs: 'ALL,BIO,PUBCHEM,MESH,HMDB,KNAPSACK,CHEBI,PUBMED,KEGG,HSDB,MACONDA,METACYC,GNPS,ZINCBIO,UNDP,YMDB,PLANTCYC,NORMAN,ADDITIONAL,PUBCHEMANNOTATIONBIO,PUBCHEMANNOTATIONDRUG,PUBCHEMANNOTATIONSAFETYANDTOXIC,PUBCHEMANNOTATIONFOOD,KEGGMINE,ECOCYCMINE,YMDBMINE'";
public static final String VALID_DATA_STRING = "Example: possible DBs: 'ALL,ALL_BUT_INSILICO,BIO,PUBCHEM,MESH,HMDB,KNAPSACK,CHEBI,PUBMED,KEGG,HSDB,MACONDA,METACYC,GNPS,ZINCBIO,UNDP,YMDB,PLANTCYC,NORMAN,ADDITIONAL,PUBCHEMANNOTATIONBIO,PUBCHEMANNOTATIONDRUG,PUBCHEMANNOTATIONSAFETYANDTOXIC,PUBCHEMANNOTATIONFOOD,KEGGMINE,ECOCYCMINE,YMDBMINE'";
public static final String PATAM_LABEL = "<dbName>[,<dbName>...]";

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import de.unijena.bioinf.chemdb.DataSource;
import de.unijena.bioinf.chemdb.DataSources;
import de.unijena.bioinf.chemdb.SearchableDatabases;
import de.unijena.bioinf.chemdb.custom.CustomDataSources;
import de.unijena.bioinf.ms.gui.utils.GuiUtils;
import de.unijena.bioinf.ms.gui.utils.jCheckboxList.JCheckBoxList;
Expand All @@ -30,15 +31,11 @@
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class DBSelectionList extends JCheckBoxList<CustomDataSources.Source> {
public final static Set<String> BLACK_LIST = Set.of(DataSource.ADDITIONAL.realName, DataSource.TRAIN.realName, DataSource.LIPID.realName(), DataSource.ALL.realName, DataSource.ALL_BUT_INSILICO.realName,
DataSource.PUBCHEMANNOTATIONBIO.realName, DataSource.PUBCHEMANNOTATIONDRUG.realName, DataSource.PUBCHEMANNOTATIONFOOD.realName, DataSource.PUBCHEMANNOTATIONSAFETYANDTOXIC.realName,
DataSource.SUPERNATURAL.realName
);


public DBSelectionList() {
this(true);
Expand All @@ -49,7 +46,7 @@ public DBSelectionList( boolean includeCustom) {

public DBSelectionList(@Nullable String descriptionKey, boolean includeCustom) {
this(descriptionKey, CustomDataSources.sourcesStream().
filter(db -> !BLACK_LIST.contains(db.name())).
filter(db -> !SearchableDatabases.NON_SLECTABLE_LIST.contains(db.name())).
filter(db -> includeCustom || !db.isCustomSource()).sorted(Comparator.comparing(CustomDataSources.Source::name)).
collect(Collectors.toList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package de.unijena.bioinf.ms.gui.compute;

import de.unijena.bioinf.chemdb.DataSource;
import de.unijena.bioinf.chemdb.SearchableDatabases;
import de.unijena.bioinf.chemdb.custom.CustomDataSources;
import de.unijena.bioinf.ms.frontend.subtools.fingerblast.FingerblastOptions;
import de.unijena.bioinf.ms.gui.utils.GuiUtils;
Expand All @@ -30,7 +31,6 @@
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -89,9 +89,7 @@ public List<String> getStructureSearchDBStrings() {
List<CustomDataSources.Source> allButInsilico = null;
private List<CustomDataSources.Source> allButInsilico(){
if (allButInsilico == null){
allButInsilico = CustomDataSources.getSourcesFromNames(
Arrays.stream(DataSource.valuesNoALLNoMINES()).map(DataSource::realName)
.filter(s -> !DBSelectionList.BLACK_LIST.contains(s)).collect(Collectors.toList()));
allButInsilico = SearchableDatabases.getNonInSilicoSelectableSources();
}
return allButInsilico;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import de.unijena.bioinf.chemdb.custom.CustomDatabase;
import de.unijena.bioinf.ms.frontend.subtools.InputFilesOptions;
import de.unijena.bioinf.ms.frontend.subtools.custom_db.CustomDBOptions;
import de.unijena.bioinf.ms.gui.compute.DBSelectionList;
import de.unijena.bioinf.ms.gui.compute.jjobs.Jobs;
import de.unijena.bioinf.ms.gui.configs.Buttons;
import de.unijena.bioinf.ms.gui.configs.Icons;
Expand Down Expand Up @@ -217,7 +216,7 @@ public void updateContent(CustomDatabase<?> c) {
content.setText("<html>Custom database. Containing "
+ c.getStatistics().getCompounds() + " compounds with " + c.getStatistics().getFormulas()
+ " different molecular formulas." +
((c.getSettings().isInheritance() ? "<br>This database will also include all compounds from '" + DataSources.getDataSourcesFromBitFlags(c.getFilterFlag()).stream().filter(n -> !DBSelectionList.BLACK_LIST.contains(n)).collect(Collectors.joining("', '")) + "'." : "")
((c.getSettings().isInheritance() ? "<br>This database will also include all compounds from '" + DataSources.getDataSourcesFromBitFlags(c.getFilterFlag()).stream().filter(n -> !SearchableDatabases.NON_SLECTABLE_LIST.contains(n)).collect(Collectors.joining("', '")) + "'." : "")
+ (c.needsUpgrade() ? "<br><b>This database schema is outdated. You have to upgrade the database before you can use it.</b>" : "") + "</html>"));
} else {
content.setText("Empty custom database.");
Expand Down

0 comments on commit 887c96d

Please sign in to comment.