From: <mg...@us...> - 2007-07-26 18:07:36
|
Revision: 774 http://obo.svn.sourceforge.net/obo/?rev=774&view=rev Author: mgibson Date: 2007-07-26 11:07:38 -0700 (Thu, 26 Jul 2007) Log Message: ----------- made a FlyGenotypeGroupAdapter that makes fly genotype strings from fly group expects the fly genotype config fields just implements makeNameFromChar from AbstractGroupAdapter Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/AbstractGroupAdapter.java phenote/trunk/src/java/phenote/dataadapter/AllFieldsGroupAdapter.java Added Paths: ----------- phenote/trunk/src/java/phenote/dataadapter/fly/FlyGenotypeGroupAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/AbstractGroupAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/AbstractGroupAdapter.java 2007-07-26 13:55:21 UTC (rev 773) +++ phenote/trunk/src/java/phenote/dataadapter/AbstractGroupAdapter.java 2007-07-26 18:07:38 UTC (rev 774) @@ -7,6 +7,7 @@ import org.geneontology.oboedit.datamodel.Namespace; import org.geneontology.oboedit.datamodel.OBOClass; import org.geneontology.oboedit.datamodel.OBOSession; +import org.geneontology.oboedit.datamodel.impl.OBOClassImpl; import org.geneontology.oboedit.datamodel.impl.OBOSessionImpl; import phenote.datamodel.CharField; @@ -18,7 +19,7 @@ import phenote.edit.CharChangeListener; import phenote.edit.CharChangeEvent; -abstract class AbstractGroupAdapter implements GroupAdapterI { +public abstract class AbstractGroupAdapter implements GroupAdapterI { private CharChangeListener charListener; private String group; @@ -61,9 +62,20 @@ getDestinationOntology().setOboSession(os); } + // protected? - subclass override? + protected OBOClass makeOboClassFromChar(CharacterI c) { + if (c.hasNoContent()) return null; // ex? + String name = makeNameFromChar(c); + String id = ":"+name; + OBOClass o = new OBOClassImpl(name,id); + o.setNamespace(getNamespace()); // ??? + return o; + } + /** This is where subclasses come in and do their thing */ - protected abstract OBOClass makeOboClassFromChar(CharacterI c); + protected abstract String makeNameFromChar(CharacterI c); + public void setDestinationField(String fieldName) { try { destinationCharField = OntologyManager.inst().getCharFieldForName(fieldName); Modified: phenote/trunk/src/java/phenote/dataadapter/AllFieldsGroupAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/AllFieldsGroupAdapter.java 2007-07-26 13:55:21 UTC (rev 773) +++ phenote/trunk/src/java/phenote/dataadapter/AllFieldsGroupAdapter.java 2007-07-26 18:07:38 UTC (rev 774) @@ -3,9 +3,6 @@ import org.apache.log4j.Logger; -import org.geneontology.oboedit.datamodel.OBOClass; -import org.geneontology.oboedit.datamodel.impl.OBOClassImpl; - import phenote.datamodel.CharField; import phenote.datamodel.CharacterI; @@ -17,9 +14,8 @@ // public boolean isFieldValueMaker() { return true; } ?? - // protected? - subclass override? - protected OBOClass makeOboClassFromChar(CharacterI c) { - if (c.hasNoContent()) return null; // ex? + + protected String makeNameFromChar(CharacterI c) { StringBuilder sb = new StringBuilder(); for (CharField cf : c.getAllCharFields()) { if (c.hasValue(cf)) @@ -28,15 +24,9 @@ if (sb.length() == 0) return null; //? sb.deleteCharAt(sb.length()-1); String name = sb.toString(); - sb.insert(0,':'); - String id = sb.toString(); - OBOClass o = new OBOClassImpl(name,id); - o.setNamespace(getNamespace()); // ??? - return o; + return name; } - - private Logger log; private Logger log() { if (log == null) log = Logger.getLogger(getClass()); Added: phenote/trunk/src/java/phenote/dataadapter/fly/FlyGenotypeGroupAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/fly/FlyGenotypeGroupAdapter.java (rev 0) +++ phenote/trunk/src/java/phenote/dataadapter/fly/FlyGenotypeGroupAdapter.java 2007-07-26 18:07:38 UTC (rev 774) @@ -0,0 +1,43 @@ +package phenote.dataadapter.fly; + +import org.apache.log4j.Logger; + +import phenote.datamodel.CharacterI; +import phenote.datamodel.CharFieldException; +import phenote.dataadapter.AbstractGroupAdapter; + +/** Makes fly style genotype from locus allele 1, locus allele 2, non locus allele, + and accesories - with datatags LA1, LA2, NLA, ACC */ + +public class FlyGenotypeGroupAdapter extends AbstractGroupAdapter { + + public FlyGenotypeGroupAdapter(String group) { + super(group); + } + protected String makeNameFromChar(CharacterI c) { + StringBuilder sb = new StringBuilder(); + try { + if (c.hasValue("LA1")) + sb.append(c.getValueString("LA1")); + if (c.hasValue("LA2")) + sb.append("/").append(c.getValueString("LA2")); + // eventually this will be a list + if (c.hasValue("NLA")) + sb.append(", ").append(c.getValueString("NLA")); + // this will also be a list + if (c.hasValue("ACC")) + sb.append(" { ").append(c.getValueString("ACC")).append(" }"); + + } catch (CharFieldException e) { + log().error(e.getMessage()); + } + return sb.toString(); + } + + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |