From: <mg...@us...> - 2006-11-23 00:41:24
|
Revision: 223 http://svn.sourceforge.net/obo/?rev=223&view=rev Author: mgibson Date: 2006-11-22 16:41:22 -0800 (Wed, 22 Nov 2006) Log Message: ----------- ammended pheno syntax adapter a little - still problems pheno xml is still broken with new paradigm Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java phenote/trunk/src/java/phenote/datamodel/Character.java phenote/trunk/src/java/phenote/datamodel/CharacterI.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java 2006-11-22 23:40:05 UTC (rev 222) +++ phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java 2006-11-23 00:41:22 UTC (rev 223) @@ -46,22 +46,31 @@ } StringBuffer sb = new StringBuffer(); - if (character.hasPub()) - sb.append("PUB=").append(character.getPub()); - // Genotype - not strictly part of pheno syntax but lets face it we need it - // i would say its an omission from syntax - sb.append(" GT=").append(character.getGenotype()); - if (character.hasGeneticContext()) - sb.append(" GC=").append(makeValue(character.getGeneticContext())); + try { - if (character.getEntity() == null) - throw new BadCharException("Error: character has no entity, ignoring"); - sb.append(" E=").append(makeValue(character.getEntity())); - - if (character.getQuality() == null) - throw new BadCharException("Error: character has no quality, ignoring"); - sb.append(" Q=").append(makeValue(character.getQuality())); - + if (character.hasValue("Pub")) // hasPub + sb.append("PUB=").append(character.getValueString("Pub")); //Pub()); + // Genotype - not strictly part of pheno syntax but lets face it we need it + // i would say its an omission from syntax + //sb.append(" GT=").append(character.getGenotype()); + sb.append(" GT=").append(character.getValueString("Genotype")); + if (character.hasValue("Genetic Context")) + sb.append(" GC=").append(makeValue(character.getTerm("Genetic Context"))); + + if (!character.hasValue("Entity")) + throw new BadCharException("Error: character has no entity, ignoring"); + //sb.append(" E=").append(makeValue(character.getEntity())); + sb.append(" E=").append(makeValue(character.getTerm("Entity"))); + + //if (character.getQuality() == null) + if (!character.hasValue("Quality")) + throw new BadCharException("Error: character has no quality, ignoring"); + sb.append(" Q=").append(makeValue(character.getTerm("Quality"))); + + } + catch (Exception e) { + throw new BadCharException(e.getMessage()); + } return sb.toString(); } @@ -77,20 +86,20 @@ return term.getID() + " /*" + term.getName() + "*/"; } - /** Merges id prefix and name, so for id GO:1234 with name "growth" returns - "GO:growth", which is readable and computable & syn acceptable - pase - doing ids*/ - private String idPrefixAndName(OBOClass term) { - return getIdPrefix(term)+term.getName(); - } +// /** Merges id prefix and name, so for id GO:1234 with name "growth" returns +// "GO:growth", which is readable and computable & syn acceptable - pase - doing ids*/ +// private String idPrefixAndName(OBOClass term) { +// return getIdPrefix(term)+term.getName(); +// } - /** for GO:12345 returns GO: - with colon! - pase - doing ids */ - private String getIdPrefix(OBOClass term) { - if (term == null) return ""; // shouldnt happen - String id = term.getID(); - int colonIndex = id.indexOf(":"); - return id.substring(0,colonIndex+1); // +1 retain colon - } +// /** for GO:12345 returns GO: - with colon! - pase - doing ids */ +// private String getIdPrefix(OBOClass term) { +// if (term == null) return ""; // shouldnt happen +// String id = term.getID(); +// int colonIndex = id.indexOf(":"); +// return id.substring(0,colonIndex+1); // +1 retain colon +// } Modified: phenote/trunk/src/java/phenote/datamodel/Character.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/Character.java 2006-11-22 23:40:05 UTC (rev 222) +++ phenote/trunk/src/java/phenote/datamodel/Character.java 2006-11-23 00:41:22 UTC (rev 223) @@ -42,13 +42,37 @@ // cfv = cf.getCharFieldEnum().getValue(this); return cfv; } + + public String getValueString(String field) throws Exception { + CharField cf = getCharFieldForName(field); // throws ex + if (!hasValue(cf)) return null; // ?? exception? + return getValue(cf).getName(); + } + + public OBOClass getTerm(String field) throws Exception { + CharField cf = getCharFieldForName(field); // throws ex + if (!hasValue(cf)) return null; // ?? exception? + return getValue(cf).getOboClass(); + } + // should this be isNull? public boolean hasValue(CharField cf) { // empty string is a valid value for non-required field - or should there // be some sort of somthing to indicate "empty" value? return getValue(cf) != null; // && !getValue(cf).equals(""); } + public boolean hasValue(String fieldName) throws Exception { + return hasValue(getCharFieldForName(fieldName)); + } + private CharField getCharFieldForName(String fieldName) throws Exception { + for (CharField cf : charFieldToValue.keySet()) { + if (cf.getName().equalsIgnoreCase(fieldName)) + return cf; + } + throw new Exception("No field for "+fieldName); + } + public String getPub() { return pub; } public boolean hasPub() { return pub!=null && !pub.equals(""); } public String getGenotype() { return genotype; } Modified: phenote/trunk/src/java/phenote/datamodel/CharacterI.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharacterI.java 2006-11-22 23:40:05 UTC (rev 222) +++ phenote/trunk/src/java/phenote/datamodel/CharacterI.java 2006-11-23 00:41:22 UTC (rev 223) @@ -34,7 +34,11 @@ /** generic fields!!! */ public void setValue(CharField cf, CharFieldValue cfv); // ?? public CharFieldValue getValue(CharField cf); + // should make an exception for this + public String getValueString(String fieldName) throws Exception; // yuck + public OBOClass getTerm(String field) throws Exception; public boolean hasValue(CharField cf); + public boolean hasValue(String fieldName) throws Exception; public CharacterI cloneCharacter(); public boolean equals(CharacterI c); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |