From a78c82836ee4a0eedad21519abca317fcc44aaf8 Mon Sep 17 00:00:00 2001 From: tjc <tjc@ee4ac58c-ac51-4696-9907-e4b3aa274f04> Date: Wed, 5 Jul 2006 12:32:28 +0000 Subject: [PATCH] implement multiple locations for chado features git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@4518 ee4ac58c-ac51-4696-9907-e4b3aa274f04 --- uk/ac/sanger/artemis/chado/ChadoDemo.java | 8 +- uk/ac/sanger/artemis/chado/ChadoFeature.java | 80 +++++++++++++++++++- uk/ac/sanger/artemis/chado/IBatisDAO.java | 2 +- 3 files changed, 84 insertions(+), 6 deletions(-) diff --git a/uk/ac/sanger/artemis/chado/ChadoDemo.java b/uk/ac/sanger/artemis/chado/ChadoDemo.java index 17d49dc42..f533a4f8d 100644 --- a/uk/ac/sanger/artemis/chado/ChadoDemo.java +++ b/uk/ac/sanger/artemis/chado/ChadoDemo.java @@ -358,8 +358,10 @@ public class ChadoDemo { feature = (ChadoFeature) featureList.get(i); - int fmin = feature.getFeatureloc().getFmin() + 1; - int fmax = feature.getFeatureloc().getFmax(); + // assume only one featureloc + ChadoFeatureLoc loc = (ChadoFeatureLoc)feature.getFeaturelocsForFeatureId().get(0); + int fmin = loc.getFmin() + 1; + int fmax = loc.getFmax(); rowData[i][0] = feature.getOrganism().getAbbreviation(); rowData[i][1] = feature.getUniquename(); @@ -367,7 +369,7 @@ public class ChadoDemo //rowData[i][2] = (String)cvterm.get(new Long(feature.getType_id())); rowData[i][3] = Integer.toString(feature.getId()); rowData[i][4] = fmin + "..." + fmax; - rowData[i][5] = Integer.toString(feature.getFeatureloc().getStrand()); + rowData[i][5] = Integer.toString(loc.getStrand()); rowData[i][6] = feature.getTimelastmodified().toString(); } return rowData; diff --git a/uk/ac/sanger/artemis/chado/ChadoFeature.java b/uk/ac/sanger/artemis/chado/ChadoFeature.java index dbd304096..eb24f47ed 100644 --- a/uk/ac/sanger/artemis/chado/ChadoFeature.java +++ b/uk/ac/sanger/artemis/chado/ChadoFeature.java @@ -26,7 +26,9 @@ package uk.ac.sanger.artemis.chado; import java.sql.Timestamp; +import java.util.HashSet; import java.util.Hashtable; +import java.util.Set; import java.util.Vector; import java.util.List; @@ -56,7 +58,7 @@ public class ChadoFeature private ChadoCvterm cvterm; /** feature property */ private ChadoFeatureProp featureprop; - /** feature location */ + /** feature location (for a given srcfeature) */ private ChadoFeatureLoc featureloc; /** feature relationship */ private ChadoFeatureRelationship feature_relationship; @@ -72,9 +74,13 @@ public class ChadoFeature private List featureRelationshipsForObjectId; /** list of ChadoFeatureRelationship parent */ private List featureRelationshipsForSubjectId; - + /** list of feature dbxrefs (ChadoFeatureDbxref) */ + private List featureDbxrefs; + /** list of feature locations for a feature_id */ + private List featurelocsForFeatureId; private List featureCvterms = new Vector(); + /** * Get the feature_id. * @return the feature_id @@ -361,28 +367,80 @@ public class ChadoFeature } } + /** + * Get a list of <code>ChadoFeatureRelationship</code> children + * @return + */ public List getFeatureRelationshipsForObjectId() { return featureRelationshipsForObjectId; } + /** + * Set a list of <code>ChadoFeatureRelationship</code> children + * @param featureRelationshipsForObjectId + */ public void setFeatureRelationshipsForObjectId( List featureRelationshipsForObjectId) { this.featureRelationshipsForObjectId = featureRelationshipsForObjectId; } + /** + * Get a list of <code>ChadoFeatureRelationship</code> parent + * @return + */ public List getFeatureRelationshipsForSubjectId() { return featureRelationshipsForSubjectId; } + /** + * Set a list of <code>ChadoFeatureRelationship</code> parent + * @param featureRelationshipsForSubjectId + */ public void setFeatureRelationshipsForSubjectId( List featureRelationshipsForSubjectId) { this.featureRelationshipsForSubjectId = featureRelationshipsForSubjectId; } + /** + * Get a list of feature dbxrefs (<code>ChadoFeatureDbxref</code>) + * @return + */ + public List getFeatureDbxrefs() + { + return featureDbxrefs; + } + + /** + * Set a list of feature dbxrefs (<code>ChadoFeatureDbxref</code>) + * @param featureDbxrefs + */ + public void setFeatureDbxrefs(List featureDbxrefs) + { + this.featureDbxrefs = featureDbxrefs; + } + + /** + * Get list of feature locations for a feature_id + * @return + */ + public List getFeaturelocsForFeatureId() + { + return featurelocsForFeatureId; + } + + /** + * Set a list of feature locations for a feature_id + * @param featurelocsForFeatureId + */ + public void setFeaturelocsForFeatureId(List featurelocsForFeatureId) + { + this.featurelocsForFeatureId = featurelocsForFeatureId; + } + /** * Used in merging the qualifiers to store them as a <code>Hashtable</code> of * the cvterm type_id (of the property name) and the property values as a @@ -419,5 +477,23 @@ public class ChadoFeature { return qualifiers; } + + /** + * Utility for finding a feature location from a List that corresponds + * to a particular srcfeature. + * @param locs List of ChadoFeatureLoc + * @param srcfeature_id srcfeature id + * @return + */ + public static ChadoFeatureLoc getFeatureLoc(List locs, int srcfeature_id) + { + for(int i=0; i<locs.size(); i++) + { + ChadoFeatureLoc loc = (ChadoFeatureLoc)locs.get(i); + if(loc.getSrcfeature_id() == srcfeature_id) + return loc; + } + return null; + } } diff --git a/uk/ac/sanger/artemis/chado/IBatisDAO.java b/uk/ac/sanger/artemis/chado/IBatisDAO.java index 7276ff54b..ad615761c 100644 --- a/uk/ac/sanger/artemis/chado/IBatisDAO.java +++ b/uk/ac/sanger/artemis/chado/IBatisDAO.java @@ -181,7 +181,7 @@ public class IBatisDAO implements ChadoDAO feature.setSchema(schema); feature.setFeatureCvterms(cvterm_ids); - return sqlMap.queryForList("getSchemaResidueFeatures", + return sqlMap.queryForList("getResidueFeatures", feature); } -- GitLab