From: <rv...@us...> - 2010-02-12 04:37:37
|
Revision: 494 http://treebase.svn.sourceforge.net/treebase/?rev=494&view=rev Author: rvos Date: 2010-02-12 04:37:30 +0000 (Fri, 12 Feb 2010) Log Message: ----------- Added DwC:DecimalLatitude and DwC:DecimalLongitude annotations Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-02-12 04:35:22 UTC (rev 493) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-02-12 04:37:30 UTC (rev 494) @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.cipres.treebase.dao.jdbc.ContinuousMatrixElementJDBC; import org.cipres.treebase.dao.jdbc.ContinuousMatrixJDBC; @@ -22,6 +23,7 @@ import org.cipres.treebase.domain.matrix.MatrixElement; import org.cipres.treebase.domain.matrix.MatrixRow; import org.cipres.treebase.domain.matrix.PhyloChar; +import org.cipres.treebase.domain.matrix.RowSegment; import org.cipres.treebase.domain.matrix.StandardMatrix; import org.cipres.treebase.domain.study.Study; import org.cipres.treebase.domain.taxon.TaxonLabelHome; @@ -292,11 +294,12 @@ DiscreteMatrix tbMatrix) { OTUs xmlOTUs = xmlMatrix.getOTUs(); List<org.nexml.model.Character> characterList = xmlMatrix.getCharacters(); - for ( MatrixRow row : tbMatrix.getRowsReadOnly() ) { - OTU xmlOTU = getOTUById(xmlOTUs, row.getTaxonLabel().getId()); + for ( MatrixRow tbRow : tbMatrix.getRowsReadOnly() ) { + Set<RowSegment> tbSegments = tbRow.getSegmentsReadOnly(); + OTU xmlOTU = getOTUById(xmlOTUs, tbRow.getTaxonLabel().getId()); int charIndex = 0; if ( characterList.size() <= MAX_GRANULAR_NCHAR && xmlOTUs.getAllOTUs().size() <= MAX_GRANULAR_NTAX ) { - for ( MatrixElement tbCell : row.getElements() ) { + for ( MatrixElement tbCell : tbRow.getElements() ) { org.nexml.model.Character xmlCharacter = characterList.get(charIndex); MatrixCell<CharacterState> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); DiscreteCharState tbState = ((DiscreteMatrixElement)tbCell).getCharState(); @@ -304,11 +307,21 @@ CharacterState xmlState = xmlCharacter.getCharacterStateSet().lookupCharacterStateBySymbol(tbSymbolString); xmlCell.setValue(xmlState); attachTreeBaseID((Annotatable)xmlCell,tbCell,DiscreteMatrixElement.class); + for ( RowSegment tbSegment : tbSegments ) { + if ( tbSegment.getStartIndex() <= charIndex && charIndex <= tbSegment.getEndIndex() ) { + if ( tbSegment.getSpecimenLabel().getLatitude() != null ) { + ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLatitude", mDwCURI, tbSegment.getSpecimenLabel().getLatitude()); + } + if ( tbSegment.getSpecimenLabel().getLongitude() != null ) { + ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLongitude", mDwCURI, tbSegment.getSpecimenLabel().getLongitude()); + } + } + } charIndex++; } } else { - String seq = row.buildElementAsString(); + String seq = tbRow.buildElementAsString(); if ( tbMatrix.getDataType().getDescription().equals(MatrixDataType.MATRIX_DATATYPE_STANDARD) ) { StringBuilder sb = new StringBuilder(); for ( int i = 0; i < seq.length(); i++ ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2010-02-15 14:01:24
|
Revision: 497 http://treebase.svn.sourceforge.net/treebase/?rev=497&view=rev Author: rvos Date: 2010-02-15 12:29:51 +0000 (Mon, 15 Feb 2010) Log Message: ----------- Added comment where genbank accession numbers should be serialized into nexml Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-02-12 07:21:53 UTC (rev 496) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-02-15 12:29:51 UTC (rev 497) @@ -315,6 +315,11 @@ if ( tbSegment.getSpecimenLabel().getLongitude() != null ) { ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLongitude", mDwCURI, tbSegment.getSpecimenLabel().getLongitude()); } + /* + if ( tbSegment.getSpecimenLabel().getGenBankAccession() != null ) { + ((Annotatable)xmlCell).addAnnotationValue(arg0, arg1, arg2) + } + */ } } charIndex++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2010-03-15 01:06:25
|
Revision: 572 http://treebase.svn.sourceforge.net/treebase/?rev=572&view=rev Author: rvos Date: 2010-03-15 01:06:19 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Now calls getAnnotations() to let the object decide what metadata to add. Where we add metadata here, we use the URIs from the Constants class as opposed to hardcoding them here. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-03-15 01:04:39 UTC (rev 571) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-03-15 01:06:19 UTC (rev 572) @@ -4,6 +4,7 @@ import java.util.List; import java.util.Set; +import org.cipres.treebase.Constants; import org.cipres.treebase.dao.jdbc.ContinuousMatrixElementJDBC; import org.cipres.treebase.dao.jdbc.ContinuousMatrixJDBC; import org.cipres.treebase.dao.jdbc.DiscreteMatrixElementJDBC; @@ -179,9 +180,9 @@ if ( null != tbState.getDescription() ) { xmlState.setLabel(tbState.getDescription()); } - if ( null != tbState.getNotes() ) { - ((Annotatable)xmlState).addAnnotationValue("dcterms:description", mDCURI, tbState.getNotes()); - } +// if ( null != tbState.getNotes() ) { +// ((Annotatable)xmlState).addAnnotationValue("dcterms:description", Constants.DCURI, tbState.getNotes()); +// } attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); } org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); @@ -222,7 +223,7 @@ org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); PhyloChar tbCharacter = tbColumn.getCharacter(); if ( null != tbCharacter.getDescription() && ! tbCharacter.getDescription().equals(tbDataType) ) { - ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", mDCURI, tbCharacter.getDescription()); + ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); } if ( null != tbCharacter.getId() && tbCharacter.getId() != 2 ) { // XXX is PhyloChar.id 2 some sort of magic number? attachTreeBaseID((Annotatable)xmlCharacter,tbCharacter,PhyloChar.class); @@ -245,7 +246,7 @@ org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(); PhyloChar tbCharacter = tbColumn.getCharacter(); if ( null != tbCharacter.getDescription() ) { - ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", mDCURI, tbCharacter.getDescription()); + ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); } attachTreeBaseID((Annotatable)xmlCharacter,tbCharacter,PhyloChar.class); } @@ -275,10 +276,6 @@ } xmlMatrix.setLabel(tbMatrix.getTitle()); attachTreeBaseID((Annotatable)xmlMatrix, tbMatrix,Matrix.class); - ((Annotatable)xmlMatrix).addAnnotationValue("tb:type.matrix", mTBTermsURI, tbMatrix.getDataType().getDescription()); - ((Annotatable)xmlMatrix).addAnnotationValue("tb:ntax.matrix", mTBTermsURI, tbMatrix.getnTax()); - ((Annotatable)xmlMatrix).addAnnotationValue("tb:nchar.matrix", mTBTermsURI, tbMatrix.getnChar()); - ((Annotatable)xmlMatrix).addAnnotationValue("tb:identifier.matrix", mTBTermsURI, tbMatrix.getId()); return xmlMatrix; } @@ -310,10 +307,10 @@ for ( RowSegment tbSegment : tbSegments ) { if ( tbSegment.getStartIndex() <= charIndex && charIndex <= tbSegment.getEndIndex() ) { if ( tbSegment.getSpecimenLabel().getLatitude() != null ) { - ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLatitude", mDwCURI, tbSegment.getSpecimenLabel().getLatitude()); + ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, tbSegment.getSpecimenLabel().getLatitude()); } if ( tbSegment.getSpecimenLabel().getLongitude() != null ) { - ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLongitude", mDwCURI, tbSegment.getSpecimenLabel().getLongitude()); + ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, tbSegment.getSpecimenLabel().getLongitude()); } /* if ( tbSegment.getSpecimenLabel().getGenBankAccession() != null ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2010-06-09 12:40:35
|
Revision: 718 http://treebase.svn.sourceforge.net/treebase/?rev=718&view=rev Author: rvos Date: 2010-06-09 12:40:28 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Attaching DarwinCore geocoding predicates to OTUs Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-06-04 11:29:49 UTC (rev 717) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-06-09 12:40:28 UTC (rev 718) @@ -306,17 +306,14 @@ attachTreeBaseID((Annotatable)xmlCell,tbCell,DiscreteMatrixElement.class); for ( RowSegment tbSegment : tbSegments ) { if ( tbSegment.getStartIndex() <= charIndex && charIndex <= tbSegment.getEndIndex() ) { - if ( tbSegment.getSpecimenLabel().getLatitude() != null ) { - ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, tbSegment.getSpecimenLabel().getLatitude()); + Double latitude = tbSegment.getSpecimenLabel().getLatitude(); + Double longitude = tbSegment.getSpecimenLabel().getLongitude(); + if ( null != latitude ) { + ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); } - if ( tbSegment.getSpecimenLabel().getLongitude() != null ) { - ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, tbSegment.getSpecimenLabel().getLongitude()); + if ( null != longitude ) { + ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); } - /* - if ( tbSegment.getSpecimenLabel().getGenBankAccession() != null ) { - ((Annotatable)xmlCell).addAnnotationValue(arg0, arg1, arg2) - } - */ } } charIndex++; @@ -335,6 +332,18 @@ } xmlMatrix.setSeq(seq,xmlOTU); } + for ( RowSegment tbSegment : tbSegments ) { + if ( tbSegment.getStartIndex() <= charIndex && charIndex <= tbSegment.getEndIndex() ) { + Double latitude = tbSegment.getSpecimenLabel().getLatitude(); + Double longitude = tbSegment.getSpecimenLabel().getLongitude(); + if ( null != latitude ) { + xmlOTU.addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); + } + if ( null != longitude ) { + xmlOTU.addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); + } + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2010-06-15 16:06:02
|
Revision: 719 http://treebase.svn.sourceforge.net/treebase/?rev=719&view=rev Author: rvos Date: 2010-06-15 16:05:56 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Attaching DarwinCore geocoding predicates to OTUs, bugfix Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-06-09 12:40:28 UTC (rev 718) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-06-15 16:05:56 UTC (rev 719) @@ -333,16 +333,14 @@ xmlMatrix.setSeq(seq,xmlOTU); } for ( RowSegment tbSegment : tbSegments ) { - if ( tbSegment.getStartIndex() <= charIndex && charIndex <= tbSegment.getEndIndex() ) { - Double latitude = tbSegment.getSpecimenLabel().getLatitude(); - Double longitude = tbSegment.getSpecimenLabel().getLongitude(); - if ( null != latitude ) { - xmlOTU.addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); - } - if ( null != longitude ) { - xmlOTU.addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); - } + Double latitude = tbSegment.getSpecimenLabel().getLatitude(); + Double longitude = tbSegment.getSpecimenLabel().getLongitude(); + if ( null != latitude ) { + xmlOTU.addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); } + if ( null != longitude ) { + xmlOTU.addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-03-22 17:45:12
|
Revision: 777 http://treebase.svn.sourceforge.net/treebase/?rev=777&view=rev Author: rvos Date: 2011-03-22 17:45:05 +0000 (Tue, 22 Mar 2011) Log Message: ----------- Added lat/lon coordinates to continuous matrices Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-03-21 20:06:58 UTC (rev 776) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-03-22 17:45:05 UTC (rev 777) @@ -358,9 +358,9 @@ ContinuousMatrix tbMatrix) { List<org.nexml.model.Character> characterList = xmlMatrix.getCharacters(); OTUs xmlOTUs = xmlMatrix.getOTUs(); - for ( MatrixRow row : tbMatrix.getRowsReadOnly() ) { - List<MatrixElement> elements = row.getElements(); - OTU xmlOTU = getOTUById(xmlOTUs, row.getTaxonLabel().getId()); + for ( MatrixRow tbRow : tbMatrix.getRowsReadOnly() ) { + List<MatrixElement> elements = tbRow.getElements(); + OTU xmlOTU = getOTUById(xmlOTUs, tbRow.getTaxonLabel().getId()); if ( characterList.size() <= MAX_GRANULAR_NCHAR && xmlOTUs.getAllOTUs().size() <= MAX_GRANULAR_NTAX ) { for ( int elementIndex = 0; elementIndex < tbMatrix.getnChar(); elementIndex++ ) { ContinuousMatrixElement tbCell = (ContinuousMatrixElement)elements.get(elementIndex); @@ -370,9 +370,20 @@ } } else { - String seq = row.buildElementAsString(); + String seq = tbRow.buildElementAsString(); xmlMatrix.setSeq(seq,xmlOTU); } + Set<RowSegment> tbSegments = tbRow.getSegmentsReadOnly(); + for ( RowSegment tbSegment : tbSegments ) { + Double latitude = tbSegment.getSpecimenLabel().getLatitude(); + Double longitude = tbSegment.getSpecimenLabel().getLongitude(); + if ( null != latitude ) { + xmlOTU.addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); + } + if ( null != longitude ) { + xmlOTU.addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-04-19 10:49:28
|
Revision: 785 http://treebase.svn.sourceforge.net/treebase/?rev=785&view=rev Author: rvos Date: 2011-04-19 10:49:22 +0000 (Tue, 19 Apr 2011) Log Message: ----------- Now setting the xml:base attribute on each matrix to <phylowsPurl>/matrix/TB2: so that we can use TreeBASE ID strings as XML IDs instead of doing the owl:sameAs stuff to attach identifiers. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-04-14 21:09:54 UTC (rev 784) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-04-19 10:49:22 UTC (rev 785) @@ -171,6 +171,7 @@ public CategoricalMatrix fromTreeBaseToXml(StandardMatrix tbMatrix) { OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); CategoricalMatrix xmlMatrix = getDocument().createCategoricalMatrix(xmlOTUs); + xmlMatrix.setBaseURI(mMatrixBaseURI); List<List<DiscreteCharState>> tbStateLabels = tbMatrix.getStateLabels(); List<MatrixColumn> tbColumns = tbMatrix.getColumnsReadOnly(); for ( int i = 0; i < tbColumns.size(); i++ ) { @@ -219,6 +220,7 @@ xmlMatrix = getDocument().createMolecularMatrix(xmlOTUs, MolecularMatrix.Protein); xmlStateSet = ((MolecularMatrix)xmlMatrix).getProteinCharacterStateSet(); } + xmlMatrix.setBaseURI(mMatrixBaseURI); for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); PhyloChar tbCharacter = tbColumn.getCharacter(); @@ -242,6 +244,7 @@ public org.nexml.model.ContinuousMatrix fromTreeBaseToXml(ContinuousMatrix tbMatrix) { OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); org.nexml.model.ContinuousMatrix xmlMatrix = getDocument().createContinuousMatrix(xmlOTUs); + xmlMatrix.setBaseURI(mMatrixBaseURI); for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(); PhyloChar tbCharacter = tbColumn.getCharacter(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lol...@us...> - 2011-06-02 19:55:38
|
Revision: 897 http://treebase.svn.sourceforge.net/treebase/?rev=897&view=rev Author: loloyohe Date: 2011-06-02 19:55:32 +0000 (Thu, 02 Jun 2011) Log Message: ----------- Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-06-02 19:55:09 UTC (rev 896) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-06-02 19:55:32 UTC (rev 897) @@ -340,15 +340,31 @@ xmlMatrix.setSeq(seq,xmlOTU); } for ( RowSegment tbSegment : tbSegments ) { + String accessionNumber = tbSegment.getSpecimenLabel().getGenBankAccession(); Double latitude = tbSegment.getSpecimenLabel().getLatitude(); Double longitude = tbSegment.getSpecimenLabel().getLongitude(); + Double elevation = tbSegment.getSpecimenLabel().getElevation(); + String collector = tbSegment.getSpecimenLabel().getCollector(); + String country = tbSegment.getSpecimenLabel().getCountry(); + if ( null != accessionNumber) { + xmlOTU.addAnnotationValue("DwC:StringGenbankAcessionNumber", Constants.DwCURI, accessionNumber); + } if ( null != latitude ) { xmlOTU.addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); } if ( null != longitude ) { xmlOTU.addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); } - } + if ( null != elevation ) { + xmlOTU.addAnnotationValue("DwC:DecimalElevation", Constants.DwCURI, elevation); + } + if ( null != collector ) { + xmlOTU.addAnnotationValue("DwC:StringCollector", Constants.DwCURI, collector); + } + if ( null != country ) { + xmlOTU.addAnnotationValue("DwC:StringCountry", Constants.DwCURI, country); + } + } } } @@ -378,16 +394,32 @@ } Set<RowSegment> tbSegments = tbRow.getSegmentsReadOnly(); for ( RowSegment tbSegment : tbSegments ) { + String accessionNumber = tbSegment.getSpecimenLabel().getGenBankAccession(); Double latitude = tbSegment.getSpecimenLabel().getLatitude(); Double longitude = tbSegment.getSpecimenLabel().getLongitude(); + Double elevation = tbSegment.getSpecimenLabel().getElevation(); + String collector = tbSegment.getSpecimenLabel().getCollector(); + String country = tbSegment.getSpecimenLabel().getCountry(); + if ( null != accessionNumber) { + xmlOTU.addAnnotationValue("DwC:StringGenbankAcessionNumber", Constants.DwCURI, accessionNumber); + } if ( null != latitude ) { xmlOTU.addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); } if ( null != longitude ) { xmlOTU.addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); } - } + if ( null != elevation ) { + xmlOTU.addAnnotationValue("DwC:DecimalElevation", Constants.DwCURI, elevation); + } + if ( null != collector ) { + xmlOTU.addAnnotationValue("DwC:StringCollector", Constants.DwCURI, collector); + } + if ( null != country ) { + xmlOTU.addAnnotationValue("DwC:StringCountry", Constants.DwCURI, country); + } + } } } - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lol...@us...> - 2011-06-24 17:02:06
|
Revision: 923 http://treebase.svn.sourceforge.net/treebase/?rev=923&view=rev Author: loloyohe Date: 2011-06-24 17:02:00 +0000 (Fri, 24 Jun 2011) Log Message: ----------- Modified NexmlMatrixConverter() fromTreeBaseToXml() methods so that they have charset functionality based on the logic from the unit tests in NexmlMatrixConverterTest. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-06-17 15:30:21 UTC (rev 922) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-06-24 17:02:00 UTC (rev 923) @@ -1,16 +1,21 @@ package org.cipres.treebase.domain.nexus.nexml; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Set; +import junit.framework.Assert; + import org.cipres.treebase.Constants; import org.cipres.treebase.dao.jdbc.ContinuousMatrixElementJDBC; import org.cipres.treebase.dao.jdbc.ContinuousMatrixJDBC; import org.cipres.treebase.dao.jdbc.DiscreteMatrixElementJDBC; import org.cipres.treebase.dao.jdbc.DiscreteMatrixJDBC; import org.cipres.treebase.dao.jdbc.MatrixColumnJDBC; +import org.cipres.treebase.domain.matrix.CharSet; import org.cipres.treebase.domain.matrix.CharacterMatrix; +import org.cipres.treebase.domain.matrix.ColumnRange; import org.cipres.treebase.domain.matrix.ContinuousChar; import org.cipres.treebase.domain.matrix.ContinuousMatrix; import org.cipres.treebase.domain.matrix.ContinuousMatrixElement; @@ -38,6 +43,7 @@ import org.nexml.model.MolecularMatrix; import org.nexml.model.OTUs; import org.nexml.model.OTU; +import org.nexml.model.Subset; public class NexmlMatrixConverter extends NexmlObjectConverter { @@ -224,6 +230,9 @@ for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); PhyloChar tbCharacter = tbColumn.getCharacter(); + if ( null != tbCharacter.getDescription() ) { + xmlCharacter.setLabel(tbCharacter.getDescription()); + } if ( null != tbCharacter.getDescription() && ! tbCharacter.getDescription().equals(tbDataType) ) { ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); } @@ -249,10 +258,41 @@ org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(); PhyloChar tbCharacter = tbColumn.getCharacter(); if ( null != tbCharacter.getDescription() ) { + xmlCharacter.setLabel(tbCharacter.getDescription()); ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); } - attachTreeBaseID((Annotatable)xmlCharacter,tbCharacter,PhyloChar.class); - } + attachTreeBaseID((Annotatable)xmlCharacter,tbCharacter,PhyloChar.class); + + //coerce the tbMatrix into a character matrix to get its character sets + CharacterMatrix tbCharacterMatrix = (CharacterMatrix)tbMatrix; + Set<CharSet> tbCharSets = tbCharacterMatrix.getCharSets(); + for ( CharSet tbCharSet : tbCharSets ) { + Collection<ColumnRange> tbColumnRanges = tbCharSet.getColumns(tbCharacterMatrix); + + for ( ColumnRange tbColumnRange : tbColumnRanges ) { + + // these are the beginning and end of the range + int tbStart = tbColumnRange.getStartColIndex(); + int tbStop = tbColumnRange.getEndColIndex(); + + // increment from beginning to end. This number is probably either null, for a + // contiguous range, or perhaps 3 for codon positions + int tbInc = 1; + // create the equivalent nexml character set + Subset nexSubset = xmlMatrix.createSubset(tbCharSet.getLabel()); + + // assign character objects to the subset. Here we get the full list + List<org.nexml.model.Character> nexCharacters = xmlMatrix.getCharacters(); + + // now we iterate over the coordinates and assign the nexml characters to the set + for ( int i = tbStart; i <= tbStop; i += tbInc ) { + nexSubset.addThing(nexCharacters.get(i)); + } + } + } + + } + return xmlMatrix; } @@ -283,6 +323,32 @@ if ( null != tb1MatrixID ) { ((Annotatable)xmlMatrix).addAnnotationValue("tb:identifier.matrix.tb1", Constants.TBTermsURI, tb1MatrixID); } + Set<CharSet> tbCharSets = tbMatrix.getCharSets(); + for ( CharSet tbCharSet : tbCharSets ) { + Collection<ColumnRange> tbColumnRanges = tbCharSet.getColumns(tbMatrix); + + for ( ColumnRange tbColumnRange : tbColumnRanges ) { + + // these are the beginning and end of the range + int tbStart = tbColumnRange.getStartColIndex(); + int tbStop = tbColumnRange.getEndColIndex(); + + // increment from beginning to end. This number is probably either null, for a + // contiguous range, or perhaps 3 for codon positions + int tbInc = 1; + // create the equivalent nexml character set + Subset nexSubset = xmlMatrix.createSubset(tbCharSet.getLabel()); + + // assign character objects to the subset. Here we get the full list + List<org.nexml.model.Character> nexCharacters = xmlMatrix.getCharacters(); + + // now we iterate over the coordinates and assign the nexml characters to the set + for ( int i = tbStart; i <= tbStop; i += tbInc ) { + nexSubset.addThing(nexCharacters.get(i)); + } + } + } + return xmlMatrix; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-06-24 20:11:16
|
Revision: 924 http://treebase.svn.sourceforge.net/treebase/?rev=924&view=rev Author: rvos Date: 2011-06-24 20:11:10 +0000 (Fri, 24 Jun 2011) Log Message: ----------- Removed unused import Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-06-24 17:02:00 UTC (rev 923) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-06-24 20:11:10 UTC (rev 924) @@ -5,8 +5,6 @@ import java.util.List; import java.util.Set; -import junit.framework.Assert; - import org.cipres.treebase.Constants; import org.cipres.treebase.dao.jdbc.ContinuousMatrixElementJDBC; import org.cipres.treebase.dao.jdbc.ContinuousMatrixJDBC; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lol...@us...> - 2011-07-11 19:11:23
|
Revision: 927 http://treebase.svn.sourceforge.net/treebase/?rev=927&view=rev Author: loloyohe Date: 2011-07-11 19:11:16 +0000 (Mon, 11 Jul 2011) Log Message: ----------- Extended fromTreeBaseToXml() methods to include more row-segment metadata annotations. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-06-29 15:09:55 UTC (rev 926) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-07-11 19:11:16 UTC (rev 927) @@ -377,14 +377,98 @@ attachTreeBaseID((Annotatable)xmlCell,tbCell,DiscreteMatrixElement.class); for ( RowSegment tbSegment : tbSegments ) { if ( tbSegment.getStartIndex() <= charIndex && charIndex <= tbSegment.getEndIndex() ) { + //declare variables for row-segment annotations + String title = tbSegment.getTitle(); + String institutionCode = tbSegment.getSpecimenLabel().getInstAcronym(); + String collectionCode = tbSegment.getSpecimenLabel().getCollectionCode(); + String catalogNumber = tbSegment.getSpecimenLabel().getCatalogNumber(); + String accessionNumber = tbSegment.getSpecimenLabel().getGenBankAccession(); + String otherAccessionNumber = tbSegment.getSpecimenLabel().getOtherAccession(); + String dateSampled = tbSegment.getSpecimenLabel().getSampleDateString(); + String scientificName = tbSegment.getSpecimenTaxonLabelAsString(); + String collector = tbSegment.getSpecimenLabel().getCollector(); Double latitude = tbSegment.getSpecimenLabel().getLatitude(); Double longitude = tbSegment.getSpecimenLabel().getLongitude(); + Double elevation = tbSegment.getSpecimenLabel().getElevation(); + String country = tbSegment.getSpecimenLabel().getCountry(); + String state = tbSegment.getSpecimenLabel().getState(); + String locality = tbSegment.getSpecimenLabel().getLocality(); + String notes = tbSegment.getSpecimenLabel().getNotes(); + + //if the value is not null, output the xmlOTU annotation. + //DwC refers to the Darwin Core term vocabulary for the associated annotation + if (null != title){ + //output name identifying the data set from which the record was derived + ((Annotatable)xmlCell).addAnnotationValue("DwC:datasetName", Constants.DwCURI, title); + } + if ( null != institutionCode ) { + //output name or acronym of institution that has custody of information referred to in record + ((Annotatable)xmlCell).addAnnotationValue("DwC:institutionCode", Constants.DwCURI, institutionCode); + } + if ( null != collectionCode ) { + //output name or code that identifies collection or data set from which record was derived + ((Annotatable)xmlCell).addAnnotationValue ("DwC:collectionCode", Constants.DwCURI, collectionCode); + } + if ( null != catalogNumber ){ + //output unique (usually) identifier for the record within data set or collection + ((Annotatable)xmlCell).addAnnotationValue("DwC:catalogNumber", Constants.DwCURI, catalogNumber); + } + if ( null != accessionNumber) { + //output a list of genetic sequence information associated with occurrence + ((Annotatable)xmlCell).addAnnotationValue("DwC:associatedSequences", Constants.DwCURI, accessionNumber); + } + if ( null != otherAccessionNumber ) { + //list of previous or alternate fully catalog numbers (i.e. Genbank) or human-used identifiers + ((Annotatable)xmlCell).addAnnotationValue("DwC:otherCatalogNumbers", Constants.DwCURI, otherAccessionNumber); + } + if ( null != dateSampled ) { + //output date sampled in ISO 8601 format + ((Annotatable)xmlCell).addAnnotationValue("DwC:eventDate", Constants.DwCURI, dateSampled); + } + if ( null != scientificName ) { + //output full scientific name + ((Annotatable)xmlCell).addAnnotationValue("DwC:scientificName", Constants.DwCURI, scientificName); + } + if ( null != collector ) { + //output names of people associated with recording of original occurrence + ((Annotatable)xmlCell).addAnnotationValue("DwC:recordedBy", Constants.DwCURI, collector); + } if ( null != latitude ) { - ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); + //output geographic latitude in decimal degrees using geodeticDatum spatial reference system + ((Annotatable)xmlCell).addAnnotationValue("DwC:decimalLatitude", Constants.DwCURI, latitude); } if ( null != longitude ) { - ((Annotatable)xmlCell).addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); + //output geographic longitude in decimal degrees using geodeticDatum spatial reference system + ((Annotatable)xmlCell).addAnnotationValue("DwC:decimalLongitude", Constants.DwCURI, longitude); } + if ( null != elevation ) { + //there are two different Darwin Core terms for elevation depending on elevation value + //outputs geographic elevation of sample + if ( elevation >= 0) { + //above local surface in meters + ((Annotatable)xmlCell).addAnnotationValue("DwC:verbatimElevation", Constants.DwCURI, elevation); + } + else { + //below local surface in meters + ((Annotatable)xmlCell).addAnnotationValue("DwC:verbatimDepth", Constants.DwCURI, elevation); + } + } + if ( null != country ) { + //output country in which location occurs + ((Annotatable)xmlCell).addAnnotationValue("DwC:country", Constants.DwCURI, country); + } + if ( null != state ) { + //output name of next smaller administrative region than country (i.e. state, province, region) + ((Annotatable)xmlCell).addAnnotationValue ("DwC:stateProvince", Constants.DwCURI, state); + } + if ( null != locality) { + //output brief description of sample location + ((Annotatable)xmlCell).addAnnotationValue("DwC:locality", Constants.DwCURI, locality); + } + if ( null != notes ) { + //output any additional information about specimen + ((Annotatable)xmlCell).addAnnotationValue("DwC:occurenceRemarks", Constants.DwCURI, notes); + } } } charIndex++; @@ -404,30 +488,98 @@ xmlMatrix.setSeq(seq,xmlOTU); } for ( RowSegment tbSegment : tbSegments ) { + //declare variables for row-segment annotations + String title = tbSegment.getTitle(); + String institutionCode = tbSegment.getSpecimenLabel().getInstAcronym(); + String collectionCode = tbSegment.getSpecimenLabel().getCollectionCode(); + String catalogNumber = tbSegment.getSpecimenLabel().getCatalogNumber(); String accessionNumber = tbSegment.getSpecimenLabel().getGenBankAccession(); + String otherAccessionNumber = tbSegment.getSpecimenLabel().getOtherAccession(); + String dateSampled = tbSegment.getSpecimenLabel().getSampleDateString(); + String scientificName = tbSegment.getSpecimenTaxonLabelAsString(); + String collector = tbSegment.getSpecimenLabel().getCollector(); Double latitude = tbSegment.getSpecimenLabel().getLatitude(); Double longitude = tbSegment.getSpecimenLabel().getLongitude(); Double elevation = tbSegment.getSpecimenLabel().getElevation(); - String collector = tbSegment.getSpecimenLabel().getCollector(); String country = tbSegment.getSpecimenLabel().getCountry(); + String state = tbSegment.getSpecimenLabel().getState(); + String locality = tbSegment.getSpecimenLabel().getLocality(); + String notes = tbSegment.getSpecimenLabel().getNotes(); + + //if the value is not null, output the xmlOTU annotation. + //DwC refers to the Darwin Core term vocabulary for the associated annotation + if (null != title){ + //output name identifying the data set from which the record was derived + xmlOTU.addAnnotationValue("DwC:datasetName", Constants.DwCURI, title); + } + if ( null != institutionCode ) { + //output name or acronym of institution that has custody of information referred to in record + xmlOTU.addAnnotationValue("DwC:institutionCode", Constants.DwCURI, institutionCode); + } + if ( null != collectionCode ) { + //output name or code that identifies collection or data set from which record was derived + xmlOTU.addAnnotationValue ("DwC:collectionCode", Constants.DwCURI, collectionCode); + } + if ( null != catalogNumber ){ + //output unique (usually) identifier for the record within data set or collection + xmlOTU.addAnnotationValue("DwC:catalogNumber", Constants.DwCURI, catalogNumber); + } if ( null != accessionNumber) { - xmlOTU.addAnnotationValue("DwC:StringGenbankAcessionNumber", Constants.DwCURI, accessionNumber); + //output a list of genetic sequence information associated with occurrence + xmlOTU.addAnnotationValue("DwC:associatedSequences", Constants.DwCURI, accessionNumber); } + if ( null != otherAccessionNumber ) { + //list of previous or alternate fully catalog numbers (i.e. Genbank) or human-used identifiers + xmlOTU.addAnnotationValue("DwC:otherCatalogNumbers", Constants.DwCURI, otherAccessionNumber); + } + if ( null != dateSampled ) { + //output date sampled in ISO 8601 format + xmlOTU.addAnnotationValue("DwC:eventDate", Constants.DwCURI, dateSampled); + } + if ( null != scientificName ) { + //output full scientific name + xmlOTU.addAnnotationValue("DwC:scientificName", Constants.DwCURI, scientificName); + } + if ( null != collector ) { + //output names of people associated with recording of original occurrence + xmlOTU.addAnnotationValue("DwC:recordedBy", Constants.DwCURI, collector); + } if ( null != latitude ) { - xmlOTU.addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); + //output geographic latitude in decimal degrees using geodeticDatum spatial reference system + xmlOTU.addAnnotationValue("DwC:decimalLatitude", Constants.DwCURI, latitude); } if ( null != longitude ) { - xmlOTU.addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); + //output geographic longitude in decimal degrees using geodeticDatum spatial reference system + xmlOTU.addAnnotationValue("DwC:decimalLongitude", Constants.DwCURI, longitude); } if ( null != elevation ) { - xmlOTU.addAnnotationValue("DwC:DecimalElevation", Constants.DwCURI, elevation); + //there are two different Darwin Core terms for elevation depending on elevation value + //outputs geographic elevation of sample + if ( elevation >= 0) { + //above local surface in meters + xmlOTU.addAnnotationValue("DwC:verbatimElevation", Constants.DwCURI, elevation); + } + else { + //below local surface in meters + xmlOTU.addAnnotationValue("DwC:verbatimDepth", Constants.DwCURI, elevation); + } } - if ( null != collector ) { - xmlOTU.addAnnotationValue("DwC:StringCollector", Constants.DwCURI, collector); - } if ( null != country ) { - xmlOTU.addAnnotationValue("DwC:StringCountry", Constants.DwCURI, country); + //output country in which location occurs + xmlOTU.addAnnotationValue("DwC:country", Constants.DwCURI, country); } + if ( null != state ) { + //output name of next smaller administrative region than country (i.e. state, province, region) + xmlOTU.addAnnotationValue ("DwC:stateProvince", Constants.DwCURI, state); + } + if ( null != locality) { + //output brief description of sample location + xmlOTU.addAnnotationValue("DwC:locality", Constants.DwCURI, locality); + } + if ( null != notes ) { + //output any additional information about specimen + xmlOTU.addAnnotationValue("DwC:occurenceRemarks", Constants.DwCURI, notes); + } } } } @@ -458,30 +610,98 @@ } Set<RowSegment> tbSegments = tbRow.getSegmentsReadOnly(); for ( RowSegment tbSegment : tbSegments ) { + //declare variables for row-segment annotations + String title = tbSegment.getTitle(); + String institutionCode = tbSegment.getSpecimenLabel().getInstAcronym(); + String collectionCode = tbSegment.getSpecimenLabel().getCollectionCode(); + String catalogNumber = tbSegment.getSpecimenLabel().getCatalogNumber(); String accessionNumber = tbSegment.getSpecimenLabel().getGenBankAccession(); + String otherAccessionNumber = tbSegment.getSpecimenLabel().getOtherAccession(); + String dateSampled = tbSegment.getSpecimenLabel().getSampleDateString(); + String scientificName = tbSegment.getSpecimenTaxonLabelAsString(); + String collector = tbSegment.getSpecimenLabel().getCollector(); Double latitude = tbSegment.getSpecimenLabel().getLatitude(); Double longitude = tbSegment.getSpecimenLabel().getLongitude(); Double elevation = tbSegment.getSpecimenLabel().getElevation(); - String collector = tbSegment.getSpecimenLabel().getCollector(); String country = tbSegment.getSpecimenLabel().getCountry(); + String state = tbSegment.getSpecimenLabel().getState(); + String locality = tbSegment.getSpecimenLabel().getLocality(); + String notes = tbSegment.getSpecimenLabel().getNotes(); + + //if the value is not null, output the xmlOTU annotation. + //DwC refers to the Darwin Core term vocabulary for the associated annotation + if (null != title){ + //output name identifying the data set from which the record was derived + xmlOTU.addAnnotationValue("DwC:datasetName", Constants.DwCURI, title); + } + if ( null != institutionCode ) { + //output name or acronym of institution that has custody of information referred to in record + xmlOTU.addAnnotationValue("DwC:institutionCode", Constants.DwCURI, institutionCode); + } + if ( null != collectionCode ) { + //output name or code that identifies collection or data set from which record was derived + xmlOTU.addAnnotationValue ("DwC:collectionCode", Constants.DwCURI, collectionCode); + } + if ( null != catalogNumber ){ + //output unique (usually) identifier for the record within data set or collection + xmlOTU.addAnnotationValue("DwC:catalogNumber", Constants.DwCURI, catalogNumber); + } if ( null != accessionNumber) { - xmlOTU.addAnnotationValue("DwC:StringGenbankAcessionNumber", Constants.DwCURI, accessionNumber); + //output a list of genetic sequence information associated with occurrence + xmlOTU.addAnnotationValue("DwC:associatedSequences", Constants.DwCURI, accessionNumber); } + if ( null != otherAccessionNumber ) { + //list of previous or alternate fully catalog numbers (i.e. Genbank) or human-used identifiers + xmlOTU.addAnnotationValue("DwC:otherCatalogNumbers", Constants.DwCURI, otherAccessionNumber); + } + if ( null != dateSampled ) { + //output date sampled in ISO 8601 format + xmlOTU.addAnnotationValue("DwC:eventDate", Constants.DwCURI, dateSampled); + } + if ( null != scientificName ) { + //output full scientific name + xmlOTU.addAnnotationValue("DwC:scientificName", Constants.DwCURI, scientificName); + } + if ( null != collector ) { + //output names of people associated with recording of original occurrence + xmlOTU.addAnnotationValue("DwC:recordedBy", Constants.DwCURI, collector); + } if ( null != latitude ) { - xmlOTU.addAnnotationValue("DwC:DecimalLatitude", Constants.DwCURI, latitude); + //output geographic latitude in decimal degrees using geodeticDatum spatial reference system + xmlOTU.addAnnotationValue("DwC:decimalLatitude", Constants.DwCURI, latitude); } if ( null != longitude ) { - xmlOTU.addAnnotationValue("DwC:DecimalLongitude", Constants.DwCURI, longitude); + //output geographic longitude in decimal degrees using geodeticDatum spatial reference system + xmlOTU.addAnnotationValue("DwC:decimalLongitude", Constants.DwCURI, longitude); } if ( null != elevation ) { - xmlOTU.addAnnotationValue("DwC:DecimalElevation", Constants.DwCURI, elevation); + //there are two different Darwin Core terms for elevation depending on elevation value + //outputs geographic elevation of sample + if ( elevation >= 0) { + //above local surface in meters + xmlOTU.addAnnotationValue("DwC:verbatimElevation", Constants.DwCURI, elevation); + } + else { + //below local surface in meters + xmlOTU.addAnnotationValue("DwC:verbatimDepth", Constants.DwCURI, elevation); + } } - if ( null != collector ) { - xmlOTU.addAnnotationValue("DwC:StringCollector", Constants.DwCURI, collector); - } if ( null != country ) { - xmlOTU.addAnnotationValue("DwC:StringCountry", Constants.DwCURI, country); + //output country in which location occurs + xmlOTU.addAnnotationValue("DwC:country", Constants.DwCURI, country); } + if ( null != state ) { + //output name of next smaller administrative region than country (i.e. state, province, region) + xmlOTU.addAnnotationValue ("DwC:stateProvince", Constants.DwCURI, state); + } + if ( null != locality) { + //output brief description of sample location + xmlOTU.addAnnotationValue("DwC:locality", Constants.DwCURI, locality); + } + if ( null != notes ) { + //output any additional information about specimen + xmlOTU.addAnnotationValue("DwC:occurenceRemarks", Constants.DwCURI, notes); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-08-25 09:08:54
|
Revision: 937 http://treebase.svn.sourceforge.net/treebase/?rev=937&view=rev Author: rvos Date: 2011-08-25 09:08:48 +0000 (Thu, 25 Aug 2011) Log Message: ----------- TreeBASE uses singleton PhyloChar objects for matrices (as a space-saving hack), so it is no good to use the PhyloChar.id to create PhyloWS URIs. Instead, we should use MatrixColumn identifiers. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-11 19:44:41 UTC (rev 936) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 09:08:48 UTC (rev 937) @@ -195,7 +195,7 @@ if ( null != tbCharacter.getDescription() ) { xmlCharacter.setLabel(tbCharacter.getDescription()); } - attachTreeBaseID((Annotatable)xmlCharacter,tbCharacter,PhyloChar.class); + attachTreeBaseID((Annotatable)xmlCharacter,tbColumns.get(i),MatrixColumn.class); } return xmlMatrix; } @@ -233,10 +233,8 @@ } if ( null != tbCharacter.getDescription() && ! tbCharacter.getDescription().equals(tbDataType) ) { ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); - } - if ( null != tbCharacter.getId() && tbCharacter.getId() != 2 ) { // XXX is PhyloChar.id 2 some sort of magic number? - attachTreeBaseID((Annotatable)xmlCharacter,tbCharacter,PhyloChar.class); } + attachTreeBaseID((Annotatable)xmlCharacter,tbColumn,MatrixColumn.class); } return xmlMatrix; } @@ -259,7 +257,7 @@ xmlCharacter.setLabel(tbCharacter.getDescription()); ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); } - attachTreeBaseID((Annotatable)xmlCharacter,tbCharacter,PhyloChar.class); + attachTreeBaseID((Annotatable)xmlCharacter,tbColumn,MatrixColumn.class); //coerce the tbMatrix into a character matrix to get its character sets CharacterMatrix tbCharacterMatrix = (CharacterMatrix)tbMatrix; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-08-25 13:57:50
|
Revision: 940 http://treebase.svn.sourceforge.net/treebase/?rev=940&view=rev Author: rvos Date: 2011-08-25 13:57:44 +0000 (Thu, 25 Aug 2011) Log Message: ----------- Molecular states in the xml should now be reconciled with the singleton identifiers in treebase Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 10:30:19 UTC (rev 939) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 13:57:44 UTC (rev 940) @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -29,6 +30,7 @@ import org.cipres.treebase.domain.matrix.PhyloChar; import org.cipres.treebase.domain.matrix.RowSegment; import org.cipres.treebase.domain.matrix.StandardMatrix; +import org.cipres.treebase.domain.matrix.StateSet; import org.cipres.treebase.domain.study.Study; import org.cipres.treebase.domain.taxon.TaxonLabelHome; import org.cipres.treebase.domain.taxon.TaxonLabelSet; @@ -184,10 +186,7 @@ CharacterState xmlState = xmlStateSet.createCharacterState(tbState.getSymbol().toString()); if ( null != tbState.getDescription() ) { xmlState.setLabel(tbState.getDescription()); - } -// if ( null != tbState.getNotes() ) { -// ((Annotatable)xmlState).addAnnotationValue("dcterms:description", Constants.DCURI, tbState.getNotes()); -// } + } attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); } org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); @@ -212,6 +211,8 @@ String tbDataType = tbMatrix.getDataType().getDescription(); MolecularMatrix xmlMatrix = null; CharacterStateSet xmlStateSet = null; + + // create the matrix and constant state set if ( tbDataType.equals(MatrixDataType.MATRIX_DATATYPE_DNA) ) { xmlMatrix = getDocument().createMolecularMatrix(xmlOTUs, MolecularMatrix.DNA); xmlStateSet = ((MolecularMatrix)xmlMatrix).getDNACharacterStateSet(); @@ -224,16 +225,28 @@ xmlMatrix = getDocument().createMolecularMatrix(xmlOTUs, MolecularMatrix.Protein); xmlStateSet = ((MolecularMatrix)xmlMatrix).getProteinCharacterStateSet(); } + + // attach base uri xmlMatrix.setBaseURI(mMatrixBaseURI); + + // lookup the equivalent state in tb and attach identifiers, only keep those in matrix + Set<CharacterState> seenStates = new HashSet<CharacterState>(); + for(StateSet tbStateSet : tbMatrix.getStateSets() ) { + for (DiscreteCharState tbState : tbStateSet.getStates() ) { + String tbSymbol = tbState.getSymbol().toString().toUpperCase(); + CharacterState xmlState = xmlStateSet.lookupCharacterStateBySymbol(tbSymbol); + if ( null == xmlState ) { + xmlState = xmlStateSet.createCharacterState(tbSymbol); + } + attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); + seenStates.add(xmlState); + } + } + xmlStateSet.setCharacterStates(seenStates); + + // create columns and attach identifiers for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); - PhyloChar tbCharacter = tbColumn.getCharacter(); - if ( null != tbCharacter.getDescription() ) { - xmlCharacter.setLabel(tbCharacter.getDescription()); - } - if ( null != tbCharacter.getDescription() && ! tbCharacter.getDescription().equals(tbDataType) ) { - ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); - } attachTreeBaseID((Annotatable)xmlCharacter,tbColumn,MatrixColumn.class); } return xmlMatrix; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-08-25 13:59:08
|
Revision: 941 http://treebase.svn.sourceforge.net/treebase/?rev=941&view=rev Author: rvos Date: 2011-08-25 13:59:02 +0000 (Thu, 25 Aug 2011) Log Message: ----------- Actually, in order to be valid xsi:type subclasses, they should spell out all possible states for dna/rna/protein, not just the ones we've seen in the database Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 13:57:44 UTC (rev 940) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 13:59:02 UTC (rev 941) @@ -229,8 +229,7 @@ // attach base uri xmlMatrix.setBaseURI(mMatrixBaseURI); - // lookup the equivalent state in tb and attach identifiers, only keep those in matrix - Set<CharacterState> seenStates = new HashSet<CharacterState>(); + // lookup the equivalent state in tb and attach identifiers for(StateSet tbStateSet : tbMatrix.getStateSets() ) { for (DiscreteCharState tbState : tbStateSet.getStates() ) { String tbSymbol = tbState.getSymbol().toString().toUpperCase(); @@ -239,10 +238,8 @@ xmlState = xmlStateSet.createCharacterState(tbSymbol); } attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); - seenStates.add(xmlState); } } - xmlStateSet.setCharacterStates(seenStates); // create columns and attach identifiers for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-08-25 14:29:25
|
Revision: 943 http://treebase.svn.sourceforge.net/treebase/?rev=943&view=rev Author: rvos Date: 2011-08-25 14:29:19 +0000 (Thu, 25 Aug 2011) Log Message: ----------- Added skos:historyNote to keep track of which version of the converter we're using Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Property Changed: ---------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 14:24:16 UTC (rev 942) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 14:29:19 UTC (rev 943) @@ -177,7 +177,11 @@ public CategoricalMatrix fromTreeBaseToXml(StandardMatrix tbMatrix) { OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); CategoricalMatrix xmlMatrix = getDocument().createCategoricalMatrix(xmlOTUs); + + // attach base uri and history note + getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); xmlMatrix.setBaseURI(mMatrixBaseURI); + List<List<DiscreteCharState>> tbStateLabels = tbMatrix.getStateLabels(); List<MatrixColumn> tbColumns = tbMatrix.getColumnsReadOnly(); for ( int i = 0; i < tbColumns.size(); i++ ) { @@ -226,8 +230,9 @@ xmlStateSet = ((MolecularMatrix)xmlMatrix).getProteinCharacterStateSet(); } - // attach base uri + // attach base uri and history note xmlMatrix.setBaseURI(mMatrixBaseURI); + getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); // lookup the equivalent state in tb and attach identifiers for(StateSet tbStateSet : tbMatrix.getStateSets() ) { @@ -259,7 +264,11 @@ public org.nexml.model.ContinuousMatrix fromTreeBaseToXml(ContinuousMatrix tbMatrix) { OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); org.nexml.model.ContinuousMatrix xmlMatrix = getDocument().createContinuousMatrix(xmlOTUs); + + // attach base uri and history note xmlMatrix.setBaseURI(mMatrixBaseURI); + getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); + for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(); PhyloChar tbCharacter = tbColumn.getCharacter(); Property changes on: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java ___________________________________________________________________ Added: svn:keywords + Rev This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-08-25 14:39:50
|
Revision: 946 http://treebase.svn.sourceforge.net/treebase/?rev=946&view=rev Author: rvos Date: 2011-08-25 14:39:44 +0000 (Thu, 25 Aug 2011) Log Message: ----------- Actually, the skos:historyNote should probably be attached to the characters, not the study Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 14:35:13 UTC (rev 945) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-08-25 14:39:44 UTC (rev 946) @@ -179,7 +179,7 @@ CategoricalMatrix xmlMatrix = getDocument().createCategoricalMatrix(xmlOTUs); // attach base uri and history note - getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); + xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); xmlMatrix.setBaseURI(mMatrixBaseURI); List<List<DiscreteCharState>> tbStateLabels = tbMatrix.getStateLabels(); @@ -232,7 +232,7 @@ // attach base uri and history note xmlMatrix.setBaseURI(mMatrixBaseURI); - getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); + xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); // lookup the equivalent state in tb and attach identifiers for(StateSet tbStateSet : tbMatrix.getStateSets() ) { @@ -267,7 +267,7 @@ // attach base uri and history note xmlMatrix.setBaseURI(mMatrixBaseURI); - getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); + xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lol...@us...> - 2011-09-12 07:10:28
|
Revision: 952 http://treebase.svn.sourceforge.net/treebase/?rev=952&view=rev Author: loloyohe Date: 2011-09-12 07:10:22 +0000 (Mon, 12 Sep 2011) Log Message: ----------- Added code starting at line 388 that fixes bug #3303002, in which some studies were not printing the matrix in NeXML. I have commented out the original code with the bug in case the new code does not work for some reason. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-09-01 18:31:45 UTC (rev 951) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-09-12 07:10:22 UTC (rev 952) @@ -384,6 +384,17 @@ OTU xmlOTU = getOTUById(xmlOTUs, tbRow.getTaxonLabel().getId()); int charIndex = 0; if ( characterList.size() <= MAX_GRANULAR_NCHAR && xmlOTUs.getAllOTUs().size() <= MAX_GRANULAR_NTAX ) { + for ( MatrixColumn tbColumn : ((CharacterMatrix)tbMatrix).getColumns() ) { + String seq = tbRow.buildElementAsString(); + xmlMatrix.setSeq(seq, xmlOTU); + org.nexml.model.Character xmlCharacter = characterList.get(charIndex); + MatrixCell<CharacterState> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); + + attachTreeBaseID ((Annotatable) xmlCell, tbColumn , DiscreteMatrixElement.class); + + //The following is commented out as tbRow.getElements() does not work directly and crashes the loop. + //The above for loop fixes this issue. + /* for ( MatrixElement tbCell : tbRow.getElements() ) { org.nexml.model.Character xmlCharacter = characterList.get(charIndex); MatrixCell<CharacterState> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); @@ -392,6 +403,8 @@ CharacterState xmlState = xmlCharacter.getCharacterStateSet().lookupCharacterStateBySymbol(tbSymbolString); xmlCell.setValue(xmlState); attachTreeBaseID((Annotatable)xmlCell,tbCell,DiscreteMatrixElement.class); + */ + for ( RowSegment tbSegment : tbSegments ) { if ( tbSegment.getStartIndex() <= charIndex && charIndex <= tbSegment.getEndIndex() ) { //declare variables for row-segment annotations This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |