Commit ca567797 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1535-chemical-search' into 'devel_16.0.x'

chemicals by target search returned resoults not bound by disease

See merge request !1337
parents 1a9a4514 1780b78c
Pipeline #46587 passed with stage
in 17 minutes and 12 seconds
minerva (16.0.0~beta.2) stable; urgency=medium
* Bug fix: search chemicals by target returned chemicals not bounded by
disease (#1535)
* Bug fix: problem with export map with submaps fixed (#1540)
* Bug fix: removing user removed backgrounds in projects created by user
(#1527)
......
package lcsb.mapviewer.annotation.data;
import java.io.Serializable;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
......@@ -319,4 +323,12 @@ public class Chemical implements Serializable, TargettingStructure {
this.getTargets().removeAll(targetsToRemove);
}
public boolean containsTarget(MiriamData miriamTarget) {
boolean result = false;
for (Target target : getTargets()) {
result |= target.getGenes().contains(new MiriamData(miriamTarget.getDataType(), miriamTarget.getResource()));
}
return result;
}
}
......@@ -2,7 +2,15 @@ package lcsb.mapviewer.annotation.services.dapi;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -14,10 +22,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import lcsb.mapviewer.annotation.data.Chemical;
import lcsb.mapviewer.annotation.data.Target;
import lcsb.mapviewer.annotation.services.dapi.dto.*;
import lcsb.mapviewer.annotation.services.dapi.dto.ChemicalEntityDto;
import lcsb.mapviewer.annotation.services.dapi.dto.ChemicalEntityDtoConverter;
import lcsb.mapviewer.annotation.services.dapi.dto.ListChemicalEntityDto;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.map.model.ModelSubmodelConnection;
......@@ -137,8 +149,10 @@ public class ChemicalParser {
ListChemicalEntityDto dto = objectMapper.readValue(content, ListChemicalEntityDto.class);
List<Chemical> chemicals = fetchChemicals(dto, disease);
for (Chemical drug : chemicals) {
result.put(drug.getChemicalId(), drug);
for (Chemical chemical : chemicals) {
if (chemical.containsTarget(target)) {
result.put(chemical.getChemicalId(), chemical);
}
}
}
return new ArrayList<>(result.values());
......@@ -183,8 +197,10 @@ public class ChemicalParser {
}
Set<String> names = new HashSet<>();
for (MiriamData hgncSymbol : hgncSymbols) {
// fetching all chemicals for big map is very memory exhaustive, therefore do it
// step by step to prevent storing everything in the memory at single point
// fetching all chemicals for big map is very memory exhaustive, therefore
// do it
// step by step to prevent storing everything in the memory at single
// point
List<Chemical> chemicals = getChemicalListByTarget(hgncSymbol, diseaseMiriam);
for (Chemical chemical : chemicals) {
names.add(chemical.getChemicalName());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment