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

ctd connector is rewritten completely using DAPI interface

parent 7c8b32bc
......@@ -14,7 +14,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import lcsb.mapviewer.annotation.data.Chemical;
import lcsb.mapviewer.annotation.data.Target;
import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator;
import lcsb.mapviewer.annotation.services.dapi.dto.*;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.model.Project;
......@@ -30,7 +29,6 @@ public class ChemicalParser {
private Logger logger = LogManager.getLogger();
private DapiConnector dapiConnector;
private HgncAnnotator hgncAnnotator;
private ChemicalEntityDtoConverter chemicalEntityDtoConverter;
......@@ -38,11 +36,9 @@ public class ChemicalParser {
false);
@Autowired
public ChemicalParser(DapiConnector dapiConnector, ChemicalEntityDtoConverter chemicalEntityDtoConverter,
HgncAnnotator hgncAnnotator) {
public ChemicalParser(DapiConnector dapiConnector, ChemicalEntityDtoConverter chemicalEntityDtoConverter) {
this.dapiConnector = dapiConnector;
this.chemicalEntityDtoConverter = chemicalEntityDtoConverter;
this.hgncAnnotator = hgncAnnotator;
}
/**
......@@ -189,6 +185,7 @@ public class ChemicalParser {
hgncSymbols.add(md);
}
}
hgncSymbols.add(new MiriamData(MiriamType.HGNC_SYMBOL, bioEntity.getName()));
}
}
Set<String> names = new HashSet<>();
......@@ -202,8 +199,11 @@ public class ChemicalParser {
return result;
}
public List<Chemical> getChemicalsByName(MiriamData diseaseId, String chemicalName) throws ChemicalSearchException {
public List<Chemical> getChemicalsByName(MiriamData disease, String chemicalName) throws ChemicalSearchException {
try {
if (disease == null) {
throw new InvalidArgumentException("disease cannot be null");
}
if (!dapiConnector.isValidConnection()) {
return null;
}
......@@ -214,7 +214,9 @@ public class ChemicalParser {
String content = dapiConnector
.getAuthenticatedContent(
url + "/drugs/?columns=sourceIdentifier&name=" + URLEncoder.encode(chemicalName, "UTF-8"));
url + "/drugs/?columns=sourceIdentifier&name=" + URLEncoder.encode(chemicalName, "UTF-8")
+ "&target_disease_identifier="
+ URLEncoder.encode(disease.getPrefixedIdentifier(), "UTF-8"));
ListChemicalEntityDto result = objectMapper.readValue(content, ListChemicalEntityDto.class);
List<Chemical> chemicals = fetchChemicals(result);
......
......@@ -93,7 +93,6 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto
}
private String getAuthenticatedContent(String string, boolean fromCache) throws DapiConnectionException {
logger.debug(string);
if (!isAuthenticated()) {
login();
}
......
......@@ -28,7 +28,6 @@ import lcsb.mapviewer.model.map.model.Model;
@Rollback(true)
public class ChemicalParserTest extends AnnotationTestFunctions {
private final MiriamData parkinsonDiseaseId = new MiriamData(MiriamType.MESH_2012, "D010300");
private final MiriamData dystoniaDisease = new MiriamData(MiriamType.MESH_2012, "C538007");
private final MiriamData bloodLossDisease = new MiriamData(MiriamType.MESH_2012, "D016063");
Logger logger = LogManager.getLogger();
......@@ -141,18 +140,9 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
@Test
public void testGetByUnknownHgnc() throws Exception {
MiriamData target = new MiriamData(MiriamType.HGNC_SYMBOL, "UNK_HGNC");
chemicalParser.getChemicalListByTarget(target, parkinsonDiseaseId);
List<Chemical> chemicals = chemicalParser.getChemicalListByTarget(target, parkinsonDiseaseId);
assertEquals(1, getWarnings().size());
}
@Test
public void testGetByEntrezTarget() throws Exception {
MiriamData target = new MiriamData(MiriamType.ENTREZ, "2643");
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, dystoniaDisease);
assertTrue(list.size() > 0);
assertEquals(0, chemicals.size());
}
@Test
......@@ -181,7 +171,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
Model model = getModelForFile("testFiles/target_chemical/target.xml", false);
project.addModel(model);
List<String> result = chemicalParser.getSuggestedQueryList(project, dystoniaDisease);
List<String> result = chemicalParser.getSuggestedQueryList(project, bloodLossDisease);
assertTrue(result.size() > 0);
}
......
......@@ -30,7 +30,7 @@
</celldesigner:listOfSpeciesAliases>
<celldesigner:listOfGroups/>
<celldesigner:listOfProteins>
<celldesigner:protein id="pr7" name="GCH1" type="GENERIC"/>
<celldesigner:protein id="pr7" name="PTI" type="GENERIC"/>
</celldesigner:listOfProteins>
<celldesigner:listOfGenes/>
<celldesigner:listOfRNAs/>
......@@ -70,7 +70,7 @@
<compartment metaid="default" id="default" size="1" units="volume"/>
</listOfCompartments>
<listOfSpecies>
<species metaid="s16" id="s16" name="GCH1" compartment="default" initialAmount="0">
<species metaid="s16" id="s16" name="PTI" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
......
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