-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into 1154-biomodels-endp…
…oint
- Loading branch information
Showing
10 changed files
with
313 additions
and
235 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
python-utils/vcutils/vcell_pipeline/prune_already_published_models.py
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,28 @@ | ||
import os | ||
import re | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
import requests | ||
from pydantic import BaseModel | ||
|
||
from vcutils.common.api_utils import download_file | ||
from vcutils.vcell_pipeline.citation import getCitation, CitationInfo, getSuggestedProjectName | ||
from vcutils.vcell_pipeline.datamodels import Publication | ||
|
||
def prune_already_published_models(target_dir: Path): | ||
response = requests.get("https://api.biosimulations.org/projects", headers={'accept': 'application/json'}) | ||
publications: list[dict] = response.json() | ||
ids = [publication["id"] for publication in publications] | ||
vcdb_pubs: set[str] = set([elem for elem in ids if "VCDB" in elem]) | ||
vcdb_ids = set([re.split("[\-_]+", parts)[1] for parts in vcdb_pubs]) | ||
files = {re.split("[\-_]+", file)[1] : file for file in os.listdir(target_dir)} | ||
|
||
for potential_id in vcdb_ids: | ||
if potential_id in files: | ||
os.remove(os.path.join(target_dir, files[potential_id])) | ||
print(f"Removed file: {files[potential_id]}") | ||
|
||
|
||
if __name__ == "__main__": | ||
prune_already_published_models("/home/ldrescher/Development/BioSim/publication_candidates/input") |
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
45 changes: 45 additions & 0 deletions
45
vcell-cli/src/main/java/org/vcell/cli/run/hdf5/NonspatialDataMapping.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,45 @@ | ||
package org.vcell.cli.run.hdf5; | ||
|
||
import org.jlibsedml.DataSet; | ||
import org.jlibsedml.Report; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class NonspatialDataMapping { | ||
private final Map<Report, Map<DataSet, List<double[]>>> dataMapping; | ||
|
||
public NonspatialDataMapping(){ | ||
this.dataMapping = new LinkedHashMap<>(); | ||
} | ||
|
||
public List<double[]> put(Report report, DataSet dataset, List<double[]> data){ | ||
if (report == null || dataset == null) throw new IllegalArgumentException("No null values allowed!"); | ||
Map<DataSet, List<double[]>> reportMap; | ||
if (!this.dataMapping.containsKey(report) ) { | ||
this.dataMapping.put(report, new LinkedHashMap<>()); | ||
} | ||
reportMap = this.dataMapping.get(report); | ||
if (!reportMap.containsKey(dataset)) return reportMap.put(dataset, data); | ||
String errorMessage = String.format("Data already recorded for Report={%s}, DataSet={%s}", report.getName(), dataset.getLabel()); | ||
throw new IllegalArgumentException(errorMessage); | ||
} | ||
|
||
public List<double[]> get(Report report, DataSet dataset){ | ||
Map<DataSet, List<double[]>> reportMap = this.getDataSetMappings(report); | ||
List<double[]> result = reportMap.get(dataset); | ||
if (result != null) return result; | ||
String errorMessage = String.format("No data can be found for Report={%s}, DataSet={%s}", report.getName(), dataset.getLabel()); | ||
throw new IllegalArgumentException(errorMessage); | ||
} | ||
|
||
public Map<DataSet, List<double[]>> getDataSetMappings(Report report){ | ||
if (this.dataMapping.containsKey(report)) return this.dataMapping.get(report); | ||
throw new IllegalArgumentException(String.format("No data for Report={%s} was found", report.getName())); | ||
} | ||
|
||
public boolean isEmpty(){ | ||
return this.dataMapping.isEmpty(); | ||
} | ||
} |
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