use of eu.etaxonomy.cdm.model.molecular.Primer 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.Primer 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.Primer in project cdmlib by cybertaxonomy.
the class PrimerDaoHibernateImpl method getPrimerUuidAndTitleCache.
/**
* {@inheritDoc}
*/
@Override
public List<UuidAndTitleCache<Primer>> getPrimerUuidAndTitleCache(Integer limitOfInitialElements, String pattern) {
Session session = getSession();
String queryString = "SELECT uuid, id, label FROM Prime ";
if (pattern != null) {
queryString += " WHERE ";
queryString += " label LIKE :pattern";
}
Query query;
query = session.createQuery(queryString);
if (limitOfInitialElements != null) {
query.setMaxResults(limitOfInitialElements);
}
if (pattern != null) {
pattern = pattern.replace("*", "%");
pattern = pattern.replace("?", "_");
pattern = pattern + "%";
query.setParameter("pattern", pattern);
}
@SuppressWarnings("unchecked") List<Object[]> result = query.list();
List<UuidAndTitleCache<Primer>> list = new ArrayList<>();
for (Object[] object : result) {
list.add(new UuidAndTitleCache<Primer>(Primer.class, (UUID) object[0], (Integer) object[1], (String) object[2]));
}
return list;
}
use of eu.etaxonomy.cdm.model.molecular.Primer in project cdmlib by cybertaxonomy.
the class PrimerDaoHibernateImpl method getPrimerUuidAndTitleCache.
@Override
public List<UuidAndTitleCache<Primer>> getPrimerUuidAndTitleCache() {
List<UuidAndTitleCache<Primer>> list = new ArrayList<UuidAndTitleCache<Primer>>();
Session session = getSession();
Query query = session.createQuery("select uuid, id, label from Primer");
@SuppressWarnings("unchecked") List<Object[]> result = query.list();
for (Object[] object : result) {
list.add(new UuidAndTitleCache<Primer>(Primer.class, (UUID) object[0], (Integer) object[1], (String) object[2]));
}
return list;
}
use of eu.etaxonomy.cdm.model.molecular.Primer in project cdmlib by cybertaxonomy.
the class AbcdGgbnParser method parseSequencingPrimers.
private void parseSequencingPrimers(NodeList sequencingPrimersList, SingleRead singleRead, Amplification amplification) {
if (sequencingPrimersList.item(0) != null && sequencingPrimersList.item(0) instanceof Element) {
Element sequencingPrimers = (Element) sequencingPrimersList.item(0);
NodeList sequencingPrimerList = sequencingPrimers.getElementsByTagName(prefix + "sequencingPrimer");
for (int i = 0; i < sequencingPrimerList.getLength(); i++) {
if (sequencingPrimerList.item(i) instanceof Element) {
Element sequencingPrimer = (Element) sequencingPrimerList.item(i);
// primer name
String primerName = AbcdParseUtility.parseFirstTextContent(sequencingPrimer.getElementsByTagName(prefix + "primerName"));
// check if primer already exists
List<Primer> matchingPrimers = cdmAppController.getPrimerService().findByLabel(primerName, MatchMode.EXACT, null, null, null, null, null).getRecords();
Primer primer = null;
if (matchingPrimers.size() == 1) {
primer = matchingPrimers.iterator().next();
return;
} else {
primer = Primer.NewInstance(null);
primer.setLabel(primerName);
}
singleRead.setPrimer(primer);
// primer sequence
NodeList primerSequenceList = sequencingPrimer.getElementsByTagName(prefix + "primerSequence");
primer.setSequence(SequenceString.NewInstance(AbcdParseUtility.parseFirstTextContent(primerSequenceList)));
// primer direction
String direction = parseFirstAttribute("Direction", primerSequenceList);
if (direction != null) {
if (direction.equals(FORWARD)) {
amplification.setForwardPrimer(primer);
} else if (direction.equals(REVERSE)) {
amplification.setReversePrimer(primer);
}
}
// reference citation
NodeList primerReferenceCitationList = sequencingPrimer.getElementsByTagName(prefix + "primerReferenceCitation");
String primerReferenceCitation = AbcdParseUtility.parseFirstTextContent(primerReferenceCitationList);
Reference reference = AbcdParseUtility.parseFirstReference(primerReferenceCitationList, cdmAppController);
primer.setPublishedIn(reference);
cdmAppController.getPrimerService().save(primer);
}
}
}
}
Aggregations