Commit 087591b4 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

mirna targets are filtered by organism

parent 724d5139
......@@ -18,6 +18,8 @@ minerva (14.0.0~alpha.0) unstable; urgency=low
inside boolean gateway
* Bug fix: CellDesigner file exported from minerva was not fully compliant
with SBML standard (#831)
* Bug fix: MiRNA targets are limited only to the organism associated with the
map (#66)
-- Sascha Herzinger <sascha.herzinger@uni.lu> Wed, 22 May 2019 10:30:00 +0200
......
......@@ -7,7 +7,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.logging.log4j.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -71,6 +72,7 @@ public class MiRNAService extends DbSearchService implements IMiRNAService {
names.add(name);
List<MiRNA> miRNAs = miRNAParser.getMiRnasByNames(names);
if (miRNAs.size() > 0) {
removeUnknownOrganisms(miRNAs.get(0), searchCriteria.getOrganisms());
return miRNAs.get(0);
}
return null;
......@@ -117,8 +119,8 @@ public class MiRNAService extends DbSearchService implements IMiRNAService {
logger.error("Problem with accessing mirna database", e);
}
for (MiRNA drug : mirnaList) {
removeUnknownOrganisms(drug, searchCriteria.getOrganisms());
for (MiRNA mirna : mirnaList) {
removeUnknownOrganisms(mirna, searchCriteria.getOrganisms());
}
Collections.sort(mirnaList, new MiRNA.NameComparator());
......@@ -128,15 +130,15 @@ public class MiRNAService extends DbSearchService implements IMiRNAService {
/**
* Removes targets for unknown organisms from the mirna.
*
* @param drug
* drug from which we want to remove targets
* @param mirna
* mirna from which we want to remove targets
* @param organisms
* organisms that should be kept
*/
private void removeUnknownOrganisms(MiRNA drug, List<MiriamData> organisms) {
private void removeUnknownOrganisms(MiRNA mirna, List<MiriamData> organisms) {
if (organisms.size() > 0) {
List<Target> toRemove = new ArrayList<Target>();
for (Target target : drug.getTargets()) {
for (Target target : mirna.getTargets()) {
boolean remove = true;
for (MiriamData organism : organisms) {
if (target.getOrganism() == null) {
......@@ -151,7 +153,7 @@ public class MiRNAService extends DbSearchService implements IMiRNAService {
toRemove.add(target);
}
}
drug.getTargets().removeAll(toRemove);
mirna.getTargets().removeAll(toRemove);
}
}
......
package lcsb.mapviewer.services.search.mirna;
import org.apache.logging.log4j.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.annotation.data.MiRNA;
import lcsb.mapviewer.annotation.data.Target;
import lcsb.mapviewer.annotation.services.TaxonomyBackend;
import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.services.ServiceTestFunctions;
import lcsb.mapviewer.services.search.mirna.IMiRNAService;
import lcsb.mapviewer.services.search.DbSearchCriteria;
public class MiRNAServiceTest extends ServiceTestFunctions {
Logger logger = LogManager.getLogger(MiRNAServiceTest.class);
......@@ -45,4 +54,22 @@ public class MiRNAServiceTest extends ServiceTestFunctions {
}
}
@Test
public void testFindMiRNAFilteredByOrganism() throws Exception {
try {
MiRNA test = miRNAService.getByName("hsa-miR-29a-3p",
new DbSearchCriteria().organisms(TaxonomyBackend.HUMAN_TAXONOMY));
assertNotNull(test);
for (Target t : test.getTargets()) {
for (MiriamData md : t.getGenes()) {
assertEquals("Only hgnc symbols should be used for gene annotations", MiriamType.HGNC_SYMBOL,
md.getDataType());
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
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