From: <ba...@us...> - 2006-09-14 17:06:19
|
Revision: 131 http://svn.sourceforge.net/obo/?rev=131&view=rev Author: balhoff Date: 2006-09-14 10:06:15 -0700 (Thu, 14 Sep 2006) Log Message: ----------- Added preliminary reading of phenoXML files to PhenoXmlAdapter. This version reads only the information written out by PhenoXmlAdapter, which is currently incomplete. Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-14 16:44:04 UTC (rev 130) +++ phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-14 17:06:15 UTC (rev 131) @@ -4,9 +4,11 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; +import java.util.List; import javax.swing.JFileChooser; +import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.bioontologies.obd.schema.pheno.BearerDocument.Bearer; @@ -22,9 +24,15 @@ //import org.bioontologies.obd.schema.pheno.*.*; import phenote.datamodel.CharacterI; +import phenote.datamodel.Character; import phenote.datamodel.CharacterListI; +import phenote.datamodel.CharacterList; +import phenote.datamodel.OntologyManager; +import phenote.datamodel.OntologyManager.TermNotFoundException; +import phenote.dataadapter.CharacterListManager; import phenote.dataadapter.DataAdapterI; + public class PhenoXmlAdapter implements DataAdapterI { private Set genotypesAlreadyAdded = new HashSet<String>(); @@ -36,7 +44,81 @@ file = new File(filename); } - public void load() {} + public void load() { + try { + File file = getFileFromUser(previousFile); + if (file == null) return; + previousFile = file; + PhenosetDocument doc = PhenosetDocument.Factory.parse(file); + Phenoset phenoset = doc.getPhenoset(); + List<PhenotypeManifestation> phenotypeManifestations = phenoset.getPhenotypeManifestationList(); + CharacterListI charList = new CharacterList(); + for (PhenotypeManifestation aManifestation : phenotypeManifestations) { + CharacterI character = new Character(); + ManifestIn mi = aManifestation.getManifestIn(); + if (mi != null) { + String genotype = mi.getGenotype(); + if (genotype != null) { + character.setGenotype(genotype); + } + } + Phenotype phenotype = aManifestation.getPhenotype(); + PhenotypeCharacter phenotypeCharacter = null; + if (phenotype != null) { + List<PhenotypeCharacter> phenotypeCharacters = phenotype.getPhenotypeCharacterList(); + if ((phenotypeCharacters != null) && (phenotypeCharacters.size() > 0)) { + // we only load the first character in the phenotype for now + phenotypeCharacter = phenotypeCharacters.get(0); + } + } + OntologyManager ontologyManager = OntologyManager.inst(); + String entityID = null; + String qualityID = null; + if (phenotypeCharacter != null) { + Bearer bearer = phenotypeCharacter.getBearer(); + if (bearer != null) { + Typeref typeref = bearer.getTyperef(); + if (typeref != null) { + entityID = typeref.getAbout(); + } + } + List<Quality> qualityList = phenotypeCharacter.getQualityList(); + if ((qualityList != null) && (qualityList.size() > 0)) { + // we only load the first quality for now + Quality quality = qualityList.get(0); + Typeref qualityTyperef = quality.getTyperef(); + if (qualityTyperef != null) { + qualityID = qualityTyperef.getAbout(); + } + } + } + if (entityID != null) { + try { + character.setEntity(ontologyManager.getOboClassWithExcep(entityID)); + } + catch (TermNotFoundException e) { + System.out.println("Entity term not found " + e); + } + } + if (qualityID != null) { + try { + character.setQuality(ontologyManager.getOboClassWithExcep(qualityID)); + } + catch (TermNotFoundException e) { + System.out.println("Quality term not found " + e); + } + } + charList.add(character); + } + CharacterListManager.inst().setCharacterList(this,charList); + } + catch (XmlException e) { + System.out.println("Failed to load file as phenoxml " + e); + } + catch (IOException e) { + System.out.println("PhenoXml read failure " + e); + } + } public void commit(CharacterListI charList) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |