use of eu.etaxonomy.cdm.model.molecular.Amplification 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.model.molecular.Amplification in project cdmlib by cybertaxonomy.
the class FullCoverageDataGenerator method createMolecular.
private void createMolecular(List<CdmBase> cdmBases) {
DnaSample dnaSample = DnaSample.NewInstance();
// Amplification
Amplification amplification = Amplification.NewInstance();
DefinedTerm dnaMarker = DefinedTerm.NewDnaMarkerInstance("My dna marker", "dna marker", null);
cdmBases.add(dnaMarker);
amplification.setDnaMarker(dnaMarker);
Institution inst = Institution.NewInstance();
amplification.setInstitution(inst);
handleEventBase(amplification);
handleAnnotatableEntity(amplification);
Primer forwardPrimer = Primer.NewInstance("forward primer");
forwardPrimer.setPublishedIn(getReference());
forwardPrimer.setSequence(SequenceString.NewInstance("my sequence"));
handleAnnotatableEntity(forwardPrimer);
Primer reversePrimer = Primer.NewInstance("reverse primer");
handleAnnotatableEntity(reversePrimer);
amplification.setForwardPrimer(forwardPrimer);
amplification.setReversePrimer(reversePrimer);
DefinedTerm purificationMethod = DefinedTerm.NewInstance(TermType.MaterialOrMethod, "purification method", "purification method", null);
cdmBases.add(purificationMethod);
MaterialOrMethodEvent purification = MaterialOrMethodEvent.NewInstance(purificationMethod, "purification method");
amplification.setPurification(purification);
handleAnnotatableEntity(purification);
handleAnnotatableEntity(purificationMethod);
amplification.setLadderUsed("ladder");
amplification.setElectrophoresisVoltage(5.5);
amplification.setGelConcentration(2.4);
amplification.setGelRunningTime(3.6);
// Amplification result
AmplificationResult amplificationResult = AmplificationResult.NewInstance(dnaSample, amplification);
amplificationResult.setSuccessful(true);
amplificationResult.setSuccessText("Very successful");
handleAnnotatableEntity(amplificationResult);
DefinedTerm cloningMethod = DefinedTerm.NewInstance(TermType.MaterialOrMethod, "cloning method", "cloning method", null);
cdmBases.add(cloningMethod);
Cloning cloning = Cloning.NewInstance(cloningMethod, "My cloning method", "my strain", forwardPrimer, reversePrimer);
amplificationResult.setCloning(cloning);
handleAnnotatableEntity(cloningMethod);
handleAnnotatableEntity(cloning);
Media gelPhoto = Media.NewInstance();
amplificationResult.setGelPhoto(gelPhoto);
// SingleRead
SingleRead singleRead = SingleRead.NewInstance();
handleAnnotatableEntity(singleRead);
amplificationResult.addSingleRead(singleRead);
MaterialOrMethodEvent readMethod = MaterialOrMethodEvent.NewInstance(null, "read method");
singleRead.setMaterialOrMethod(readMethod);
handleAnnotatableEntity(readMethod);
Media pherogram = Media.NewInstance();
singleRead.setPherogram(pherogram);
singleRead.setPrimer(forwardPrimer);
singleRead.setSequence(SequenceString.NewInstance("ABTC"));
singleRead.setDirection(SequenceDirection.Forward);
// Sequence
Sequence sequence = Sequence.NewInstance("ADDT");
dnaSample.addSequence(sequence);
// SequenceString alignedSequence = SequenceString.NewInstance("AGTC");
Shift[] shifts = new Shift[] { new Shift(66, 1), new Shift(103, -2) };
SingleReadAlignment.NewInstance(sequence, singleRead, shifts, "AGTC");
Media contigFile = Media.NewInstance();
sequence.setContigFile(contigFile);
sequence.setIsBarcode(true);
sequence.setDnaMarker(dnaMarker);
sequence.setBarcodeSequencePart(SequenceString.NewInstance("ADTA"));
sequence.setGeneticAccessionNumber("GenNO12345");
sequence.setBoldProcessId("boldId");
sequence.setHaplotype("haplotype");
Reference sequenceCitation = getReference();
sequence.addCitation(sequenceCitation);
handleAnnotatableEntity(sequence);
// DnaQuality
DnaQuality dnaQuality = DnaQuality.NewInstance();
dnaQuality.setConcentration(2.0);
MeasurementUnit mu = MeasurementUnit.NewInstance("mg/ml", "mg/ml", "mg/ml");
cdmBases.add(mu);
dnaQuality.setConcentrationUnit(mu);
dnaQuality.setPurificationMethod("purification method");
dnaQuality.setQualityCheckDate(DateTime.now());
// TODO
dnaQuality.setQualityTerm(null);
dnaQuality.setRatioOfAbsorbance260_230(22.0);
dnaQuality.setRatioOfAbsorbance260_280(3.9);
dnaSample.setDnaQuality(dnaQuality);
// Phylogenetic Tree
PhylogeneticTree phyloTree = PhylogeneticTree.NewInstance();
phyloTree.addUsedSequences(sequence);
handleIdentifiableEntity(phyloTree);
cdmBases.add(dnaSample);
cdmBases.add(phyloTree);
}
use of eu.etaxonomy.cdm.model.molecular.Amplification in project cdmlib by cybertaxonomy.
the class AmplificationDaoHibernateImpl method getAmplificationUuidAndLabelCache.
@Override
public List<UuidAndTitleCache<Amplification>> getAmplificationUuidAndLabelCache(Integer limit, String pattern) {
List<UuidAndTitleCache<Amplification>> list = new ArrayList<UuidAndTitleCache<Amplification>>();
Session session = getSession();
Query query;
if (pattern != null) {
query = session.createQuery("select uuid, id, labelCache from Amplification where labelCache like :pattern");
query.setParameter("pattern", pattern);
} else {
query = session.createQuery("select uuid, id, labelCache from Amplification");
}
if (limit != null) {
query.setMaxResults(limit);
}
@SuppressWarnings("unchecked") List<Object[]> result = query.list();
for (Object[] object : result) {
list.add(new UuidAndTitleCache<Amplification>(Amplification.class, (UUID) object[0], (Integer) object[1], (String) object[2]));
}
return list;
}
use of eu.etaxonomy.cdm.model.molecular.Amplification in project cdmlib by cybertaxonomy.
the class CdmPreDataChangeListener method generateCaches.
// TODO shouldn't we use the "updateCaches" method instead?
public static void generateCaches(Object entity) {
if (entity != null) {
entity = CdmBase.deproxy(entity);
Class<?> entityClazz = entity.getClass();
if (IdentifiableEntity.class.isAssignableFrom(entityClazz)) {
IdentifiableEntity<?> identifiableEntity = (IdentifiableEntity<?>) entity;
if (TaxonName.class.isAssignableFrom(entityClazz)) {
// non-viral-name caches (was NonViralName)
TaxonName nonViralName = (TaxonName) entity;
nonViralName.getAuthorshipCache();
nonViralName.getNameCache();
nonViralName.getTitleCache();
nonViralName.getFullTitleCache();
} else if (TeamOrPersonBase.class.isAssignableFrom(entityClazz)) {
// team-or-person caches
TeamOrPersonBase<?> teamOrPerson = (TeamOrPersonBase<?>) entity;
if (teamOrPerson.isInstanceOf(Team.class)) {
Team team = CdmBase.deproxy(teamOrPerson, Team.class);
if (!team.isProtectedNomenclaturalTitleCache()) {
team.setNomenclaturalTitleCache(null, false);
}
if (!team.isProtectedCollectorTitleCache()) {
team.setCollectorTitleCache(null, false);
}
}
teamOrPerson.getNomenclaturalTitleCache();
teamOrPerson.getCollectorTitleCache();
if (!teamOrPerson.isProtectedTitleCache()) {
teamOrPerson.setTitleCache(teamOrPerson.generateTitle(), false);
}
// if the above is changed in future, change also in ImportDeduplicationHelper.initAuthorTitleCaches
} else if (Reference.class.isAssignableFrom(entityClazz)) {
// reference caches
Reference ref = (Reference) entity;
ref.getAbbrevTitleCache();
ref.getTitleCache();
} else if (SpecimenOrObservationBase.class.isAssignableFrom(entityClazz)) {
// specimen
SpecimenOrObservationBase<?> specimen = (SpecimenOrObservationBase<?>) entity;
if (!specimen.isProtectedTitleCache()) {
specimen.setTitleCache(specimen.generateTitle(), false);
}
// any other
} else {
// identifiableEntity.setTitleCache(identifiableEntity.generateTitle(), identifiableEntity.isProtectedTitleCache());
identifiableEntity.getTitleCache();
}
// titleCache should never be empty, even if protected #5763, #5849
if (identifiableEntity.isProtectedTitleCache() && identifiableEntity.hasEmptyTitleCache()) {
identifiableEntity.setTitleCache(null, false);
identifiableEntity.getTitleCache();
}
if (identifiableEntity.hasEmptyTitleCache()) {
identifiableEntity.setTitleCache(identifiableEntity.toString(), false);
}
} else if (Amplification.class.isAssignableFrom(entityClazz)) {
Amplification amplification = (Amplification) entity;
amplification.updateCache();
}
}
}
use of eu.etaxonomy.cdm.model.molecular.Amplification in project cdmlib by cybertaxonomy.
the class CacheStrategyGeneratorTest method testOnSaveOrUpdateAmplification.
@Test
public // @ExpectedDataSet
void testOnSaveOrUpdateAmplification() {
Amplification amplification = Amplification.NewInstance();
UUID amplUuid = UUID.fromString("11e6b2d5-3eb5-4434-9c56-5bb4c1102147");
amplification.setUuid(amplUuid);
amplificationDao.save(amplification);
Assert.assertEquals("<Amplification:11e6b2d5-3eb5-4434-9c56-5bb4c1102147>", amplification.getLabelCache());
Person author = Person.NewTitledInstance("Person");
Institution institution = Institution.NewInstance();
institution.setName("My institute");
DefinedTerm marker = DefinedTerm.NewDnaMarkerInstance("marker", "marker", "dm");
amplification.setActor(author);
amplification.setTimeperiod(TimePeriodParser.parseString("2008"));
amplification.setDnaMarker(marker);
amplification.setInstitution(institution);
termDao.save(marker);
amplificationDao.saveOrUpdate(amplification);
Assert.assertEquals("My institute_Person_marker_2008", amplification.getLabelCache());
}
Aggregations