use of eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator in project cdmlib by cybertaxonomy.
the class AbcdGgbnImportTest method testImportGgbn.
/**
* Tests import import of DNA unit and all its parameters
* and sub derivatives (sequence, amplification, etc.)
* @throws ParseException
*/
@Test
@DataSet(value = "/eu/etaxonomy/cdm/database/ClearDBDataSet.xml", loadStrategy = CleanSweepInsertLoadStrategy.class)
public void testImportGgbn() throws ParseException {
String inputFile = "/eu/etaxonomy/cdm/io/specimen/abcd206/in/db6_without_association.xml";
URL url = this.getClass().getResource(inputFile);
assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
Abcd206ImportConfigurator importConfigurator = null;
try {
importConfigurator = Abcd206ImportConfigurator.NewInstance(new URI(url), null, false);
} catch (URISyntaxException e) {
e.printStackTrace();
Assert.fail();
}
assertNotNull("Configurator could not be created", importConfigurator);
boolean result = defaultImport.invoke(importConfigurator).isSuccess();
assertTrue("Return value for import.invoke should be true", result);
assertEquals("Number of derived units is incorrect", 1, occurrenceService.count(DerivedUnit.class));
assertEquals("Number of dna samples is incorrect", 1, occurrenceService.count(DnaSample.class));
assertEquals("Number of field units is incorrect", 1, occurrenceService.count(FieldUnit.class));
// dna sample
FindOccurrencesConfigurator dnaConfig = new FindOccurrencesConfigurator();
dnaConfig.setSignificantIdentifier("DB 6");
List<SpecimenOrObservationBase> dnaRecords = occurrenceService.findByTitle(dnaConfig).getRecords();
assertEquals(1, dnaRecords.size());
SpecimenOrObservationBase dnaSpecimen = dnaRecords.iterator().next();
assertEquals(DnaSample.class, dnaSpecimen.getClass());
DnaSample dnaSample = (DnaSample) dnaSpecimen;
DerivationEvent derivedFrom = dnaSample.getDerivedFrom();
assertNotNull(derivedFrom);
assertEquals("Wrong derivation type!", DerivationEventType.DNA_EXTRACTION(), derivedFrom.getType());
assertEquals("Wrong number of originals", 1, derivedFrom.getOriginals().size());
assertTrue(derivedFrom.getOriginals().iterator().next() instanceof FieldUnit);
assertEquals("DNA Bank", dnaSample.getCollection().getCode());
assertEquals(SpecimenOrObservationType.DnaSample, dnaSample.getRecordBasis());
// preservation/preparation
assertNotNull(derivedFrom.getActor());
assertEquals("Bansemer, Jana", derivedFrom.getActor().getTitleCache());
assertNotNull(derivedFrom.getTimeperiod());
assertEquals((Integer) 2002, derivedFrom.getTimeperiod().getStartYear());
assertEquals((Integer) 8, derivedFrom.getTimeperiod().getStartMonth());
assertEquals((Integer) 13, derivedFrom.getTimeperiod().getStartDay());
assertNotNull(dnaSample.getPreservation());
assertEquals("DNeasy Plant Mini Spin Kit Qiagen", derivedFrom.getDescription());
// sample designation
Set<String> identifiers = dnaSample.getIdentifierStrings((DefinedTerm) termService.find(DefinedTerm.uuidSampleDesignation));
assertNotNull(identifiers);
assertEquals(1, identifiers.size());
assertEquals("CAM010", identifiers.iterator().next());
// dna quality
DnaQuality dnaQuality = dnaSample.getDnaQuality();
assertNotNull("Dna quality is null", dnaQuality != null);
assertEquals(new Double("0.77"), dnaQuality.getRatioOfAbsorbance260_230());
assertEquals(new Double("1.38"), dnaQuality.getRatioOfAbsorbance260_280());
assertEquals(new DateTime(2008, 4, 15, 0, 0), dnaQuality.getQualityCheckDate());
// assertEquals(MeasurementUnit.NewInstance(, label, labelAbbrev)DateTime(2008, 4, 15, 0, 0),dnaQuality.getQualityCheckDate());
// amplifications
Set<AmplificationResult> amplificationResults = dnaSample.getAmplificationResults();
assertNotNull(amplificationResults);
assertEquals(1, amplificationResults.size());
AmplificationResult amplificationResult = amplificationResults.iterator().next();
Amplification amplification = amplificationResult.getAmplification();
assertNotNull("Amplification is null", amplification);
DefinedTerm dnaMarker = amplification.getDnaMarker();
assertNotNull(dnaMarker);
assertEquals("ITS (ITS1, 5.8S rRNA, ITS2)", dnaMarker.getLabel());
// amplification primers
Primer forwardPrimer = amplification.getForwardPrimer();
assertNotNull(forwardPrimer);
assertEquals("PIpetB1411F", forwardPrimer.getLabel());
assertEquals("5´-GCCGTMTTTATGTTAATGC-3´", forwardPrimer.getSequence().getString());
assertNotNull(forwardPrimer.getPublishedIn());
assertEquals("Löhne & Borsch 2005", forwardPrimer.getPublishedIn().getTitle());
Primer reversePrimer = amplification.getReversePrimer();
assertNotNull(reversePrimer);
assertEquals("PIpetD738R", reversePrimer.getLabel());
assertEquals("5´-AATTTAGCYCTTAATACAGG-3´", reversePrimer.getSequence().getString());
// sequencing
Set<Sequence> sequences = dnaSample.getSequences();
assertNotNull(sequences);
assertEquals(1, sequences.size());
Sequence sequence = sequences.iterator().next();
SequenceString consensusSequence = sequence.getConsensusSequence();
assertNotNull(consensusSequence);
assertEquals("TTTCGGGTCC TTTATAGTGA AGATATAGCA TAGATAGTTG TAATCCATTA" + " TGTATCATTG GGGAAGGAAG GAGAATATTT TTTTGATAGA ATACAAGTAT" + " GGATTATTGA AACTAATACG CCATGTATTT GGATATTTCC CTTGAACTGC" + " ATAATATTCT TTATTTTCCA TGAATAGTGT AAGGGAATTT TTCGAAGAGA" + " AAATGGATTA TGGGAGTGTG TGACTTGAGC TATTGATTGG TCTGTGCAGA" + " TACGGGCTTT TATCTATCTG CCACATTGTA ATTCACAAAC CAATGTGTCT" + " TTGTTCCAAC CATCGCGTAA GCCCCATACA GAAGATAGGC TGGTTCGCTT" + " GAAGAGAATC TTTTCTATGA TCAGATCCGA ATTATGTCGT ACATGAGCAG" + " GCTCCGTAAG ATCTAGTTGA CTTAAGTCAA ACTTCAATAG TATAAAAATG" + " CACTCATTTC CTCTGCATTG ACACGAGCTA TGAGACTATC GGAGTGAAAG" + " AAAGGGTCTA AAGAAGAAGA AAGCTTGGGC TAGATTAGTA ACAAGTAAAT" + " CCTTTGTGTG TGTGTTTGTA ATTAGTAAAT GGGCTCTCAA TATTTTGGGG" + " CTAATTACTG ATCCTAAGGT TTGAGACGAC CCAGAAAGCA CTTGATCATA" + " TCACGATTGA CTTTGTAAGC CTACTTGGGT ATTGAGTATT TACTTGTAAG" + " AACCGAATTC TTTGGGGGAT AGTTGCAAAA AGAATCCAGT CAATTGTTCT" + " TACGTAAAAC CATTCATATC TCGTATATGG ATATGTCTAG ATAGGCTATC" + " GATTTTCGAT GGATTCGTTT GGTTCTTTTG ATTATTGCTC GAGCTGGATG" + " ATGAAAAATT ATCATGTCCG GTTCCTTCG", consensusSequence.getString());
// assertEquals((Integer)912, consensusSequence.getLength());
assertNotNull(sequence.getContigFile());
assertEquals(URI.create("http://ww2.biocase.org/websvn/filedetails.php?repname=campanula&path=%2FCAM385_Campa_drabifolia.pde"), MediaUtils.getFirstMediaRepresentationPart(sequence.getContigFile()).getUri());
assertEquals(1, sequence.getCitations().size());
Reference reference = sequence.getCitations().iterator().next();
assertEquals("Gemeinholzer,B., Bachmann,K. (2005): Examining morphological " + "and molecular diagnostic character states in " + "Cichorium intybus L. (Asteraceae) and Cichorium spinosum L." + " Plant Systematics and Evolution 253 (1-3): 105-123.", reference.getTitle());
// single reads
Set<SingleRead> singleReads = sequence.getSingleReads();
assertNotNull(singleReads);
assertEquals(2, singleReads.size());
for (SingleRead singleRead : singleReads) {
if (singleRead.getDirection().equals(SequenceDirection.Forward)) {
assertNotNull(singleRead.getPherogram());
assertEquals(URI.create("http://ww2.biocase.org/websvn/filedetails.php?repname=campanula&path=%2FCAM385_GM312-petD_F.ab1"), MediaUtils.getFirstMediaRepresentationPart(singleRead.getPherogram()).getUri());
} else {
assertNotNull(singleRead.getPherogram());
assertEquals(URI.create("http://ww2.biocase.org/websvn/filedetails.php?repname=campanula&path=%2FCAM385_GM312-petD_R.ab1"), MediaUtils.getFirstMediaRepresentationPart(singleRead.getPherogram()).getUri());
}
}
assertNotNull(amplificationResult.getSingleReads());
assertEquals(amplificationResult.getSingleReads(), singleReads);
}
use of eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator in project cdmlib by cybertaxonomy.
the class TaxonController method doCountSpecimensOrObservations.
@RequestMapping(value = "specimensOrObservationsCount", method = RequestMethod.GET)
public StringResultDTO doCountSpecimensOrObservations(@PathVariable("uuid") UUID uuid, HttpServletRequest request, HttpServletResponse response) {
logger.info("doListSpecimensOrObservations() - " + request.getRequestURI());
List<OrderHint> orderHints = new ArrayList<>();
orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING));
FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
config.setAssociatedTaxonUuid(uuid);
long countSpecimen = occurrenceService.countOccurrences(config);
return new StringResultDTO(String.valueOf(countSpecimen));
}
use of eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator in project cdmlib by cybertaxonomy.
the class AbcdGgbnImportTest method testImportAssociatedSpecimenSamePopulation.
/**
* Tests import of DNA unit which is associated to a specimen being its sibling
* by having the same field unit
*/
@Test
@DataSet(value = "/eu/etaxonomy/cdm/database/ClearDBDataSet.xml", loadStrategy = CleanSweepInsertLoadStrategy.class)
public // @Ignore
void testImportAssociatedSpecimenSamePopulation() {
String inputFile = "/eu/etaxonomy/cdm/io/specimen/abcd206/in/db6_sibling_association.xml";
URL url = this.getClass().getResource(inputFile);
assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
Abcd206ImportConfigurator importConfigurator = null;
try {
importConfigurator = Abcd206ImportConfigurator.NewInstance(new URI(url), null, false);
} catch (URISyntaxException e) {
e.printStackTrace();
Assert.fail();
}
assertNotNull("Configurator could not be created", importConfigurator);
boolean result = defaultImport.invoke(importConfigurator).isSuccess();
assertTrue("Return value for import.invoke should be true", result);
assertEquals("Number of derived units is incorrect", 2, occurrenceService.count(DerivedUnit.class));
assertEquals("Number of dna samples is incorrect", 1, occurrenceService.count(DnaSample.class));
assertEquals("Number of field units is incorrect", 1, occurrenceService.count(FieldUnit.class));
// associated specimen
FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
config.setSignificantIdentifier("B 10 0066577");
List<SpecimenOrObservationBase> records = occurrenceService.findByTitle(config).getRecords();
assertEquals(1, records.size());
SpecimenOrObservationBase<?> derivedUnitSpecimen = records.iterator().next();
assertEquals(DerivedUnit.class, derivedUnitSpecimen.getClass());
DerivedUnit specimen = (DerivedUnit) derivedUnitSpecimen;
assertEquals("Herbarium Berolinense", specimen.getCollection().getCode());
assertTrue(SpecimenOrObservationType.DnaSample != specimen.getRecordBasis());
// dna sample
FindOccurrencesConfigurator dnaConfig = new FindOccurrencesConfigurator();
dnaConfig.setSignificantIdentifier("DB 6");
List<SpecimenOrObservationBase> dnaRecords = occurrenceService.findByTitle(dnaConfig).getRecords();
assertEquals(1, dnaRecords.size());
SpecimenOrObservationBase<?> dnaSpecimen = dnaRecords.iterator().next();
assertEquals(DnaSample.class, dnaSpecimen.getClass());
DnaSample dnaSample = (DnaSample) dnaSpecimen;
DerivationEvent derivedFrom = dnaSample.getDerivedFrom();
assertNotNull(derivedFrom);
assertEquals("Wrong derivation type!", DerivationEventType.DNA_EXTRACTION(), derivedFrom.getType());
assertEquals("Wrong number of originals", 1, derivedFrom.getOriginals().size());
// TODO
// assertTrue(derivedFrom.getOriginals().iterator().next() instanceof FieldUnit);
assertEquals("DNA Bank", dnaSample.getCollection().getCode());
assertEquals(SpecimenOrObservationType.DnaSample, dnaSample.getRecordBasis());
// TODO field unit
}
use of eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator in project cdmlib by cybertaxonomy.
the class OccurrenceServiceImpl method findByTitle.
@Override
public <S extends SpecimenOrObservationBase> Pager<S> findByTitle(IIdentifiableEntityServiceConfigurator<S> config) {
if (config instanceof FindOccurrencesConfigurator) {
FindOccurrencesConfigurator occurrenceConfig = (FindOccurrencesConfigurator) config;
List<SpecimenOrObservationBase> occurrences = new ArrayList<>();
Taxon taxon = null;
if (occurrenceConfig.getAssociatedTaxonUuid() != null) {
TaxonBase<?> taxonBase = taxonService.load(occurrenceConfig.getAssociatedTaxonUuid());
if (taxonBase.isInstanceOf(Taxon.class)) {
taxon = HibernateProxyHelper.deproxy(taxonBase, Taxon.class);
}
}
TaxonName taxonName = null;
if (occurrenceConfig.getAssociatedTaxonNameUuid() != null) {
taxonName = nameService.load(occurrenceConfig.getAssociatedTaxonNameUuid());
}
List<? extends SpecimenOrObservationBase> foundOccurrences = dao.findOccurrences(occurrenceConfig.getClazz(), occurrenceConfig.getTitleSearchString(), occurrenceConfig.getSignificantIdentifier(), occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(), null, null, occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
occurrences.addAll(foundOccurrences);
occurrences = filterOccurencesByAssignmentAndHierarchy(occurrenceConfig, occurrences, taxon, taxonName);
long count = Integer.valueOf(occurrences.size()).longValue();
return new DefaultPagerImpl<>(config.getPageNumber(), count, config.getPageSize(), (List<S>) occurrences);
}
return super.findByTitle(config);
}
use of eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator in project cdmlib by cybertaxonomy.
the class AbcdGgbnImportTest method testImportAssociatedSpecimenSameIndividual.
/**
* Tests import of DNA unit which is associated to a specimen being its parent derivative
* @throws ParseException
*/
@Test
@DataSet(value = "/eu/etaxonomy/cdm/database/ClearDBDataSet.xml", loadStrategy = CleanSweepInsertLoadStrategy.class)
public void testImportAssociatedSpecimenSameIndividual() throws ParseException {
String inputFile = "/eu/etaxonomy/cdm/io/specimen/abcd206/in/db6_parent_child_association.xml";
URL url = this.getClass().getResource(inputFile);
assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
Abcd206ImportConfigurator importConfigurator = null;
try {
importConfigurator = Abcd206ImportConfigurator.NewInstance(new URI(url), null, false);
} catch (URISyntaxException e) {
e.printStackTrace();
Assert.fail();
}
assertNotNull("Configurator could not be created", importConfigurator);
boolean result = defaultImport.invoke(importConfigurator).isSuccess();
assertTrue("Return value for import.invoke should be true", result);
assertEquals("Number of derived units is incorrect", 2, occurrenceService.count(DerivedUnit.class));
assertEquals("Number of dna samples is incorrect", 1, occurrenceService.count(DnaSample.class));
assertEquals("Number of field units is incorrect", 1, occurrenceService.count(FieldUnit.class));
// associated specimen
FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
config.setSignificantIdentifier("B 10 0066577");
List<SpecimenOrObservationBase> records = occurrenceService.findByTitle(config).getRecords();
assertEquals(1, records.size());
SpecimenOrObservationBase derivedUnitSpecimen = records.iterator().next();
assertEquals(DerivedUnit.class, derivedUnitSpecimen.getClass());
DerivedUnit specimen = (DerivedUnit) derivedUnitSpecimen;
assertEquals("Herbarium Berolinense", specimen.getCollection().getCode());
assertTrue(SpecimenOrObservationType.DnaSample != specimen.getRecordBasis());
// dna sample
FindOccurrencesConfigurator dnaConfig = new FindOccurrencesConfigurator();
dnaConfig.setSignificantIdentifier("DB 6");
List<SpecimenOrObservationBase> dnaRecords = occurrenceService.findByTitle(dnaConfig).getRecords();
assertEquals(1, dnaRecords.size());
SpecimenOrObservationBase dnaSpecimen = dnaRecords.iterator().next();
assertEquals(DnaSample.class, dnaSpecimen.getClass());
DnaSample dnaSample = (DnaSample) dnaSpecimen;
DerivationEvent derivedFrom = dnaSample.getDerivedFrom();
assertNotNull(derivedFrom);
assertEquals("Wrong derivation type!", DerivationEventType.DNA_EXTRACTION(), derivedFrom.getType());
assertEquals("Wrong number of originals", 1, derivedFrom.getOriginals().size());
assertTrue(derivedFrom.getOriginals().iterator().next() instanceof DerivedUnit);
assertEquals("DNA Bank", dnaSample.getCollection().getCode());
assertEquals(SpecimenOrObservationType.DnaSample, dnaSample.getRecordBasis());
}
Aggregations