extensions/net.sf.basedb.varsearch/trunk/src/net/sf/basedb/varsearch/dao/Rawdatatype.java

Code
Comments
Other
Rev Date Author Line
6111 29 Jan 21 nicklas 1 package net.sf.basedb.varsearch.dao;
6111 29 Jan 21 nicklas 2
6111 29 Jan 21 nicklas 3 import java.util.List;
6111 29 Jan 21 nicklas 4
6111 29 Jan 21 nicklas 5 import net.sf.basedb.core.DbControl;
6111 29 Jan 21 nicklas 6 import net.sf.basedb.core.Include;
6111 29 Jan 21 nicklas 7 import net.sf.basedb.core.ItemQuery;
6111 29 Jan 21 nicklas 8 import net.sf.basedb.core.Platform;
6111 29 Jan 21 nicklas 9 import net.sf.basedb.core.PlatformVariant;
6111 29 Jan 21 nicklas 10 import net.sf.basedb.core.RawDataType;
6111 29 Jan 21 nicklas 11 import net.sf.basedb.core.RawDataTypes;
6111 29 Jan 21 nicklas 12 import net.sf.basedb.core.Type;
6111 29 Jan 21 nicklas 13 import net.sf.basedb.core.query.Expressions;
6111 29 Jan 21 nicklas 14 import net.sf.basedb.core.query.Hql;
6111 29 Jan 21 nicklas 15 import net.sf.basedb.core.query.Restrictions;
6111 29 Jan 21 nicklas 16
6111 29 Jan 21 nicklas 17 /**
6111 29 Jan 21 nicklas 18   Used to define raw data types. 
6111 29 Jan 21 nicklas 19   
6111 29 Jan 21 nicklas 20   @author nicklas
6111 29 Jan 21 nicklas 21 */
6111 29 Jan 21 nicklas 22 public class Rawdatatype 
6111 29 Jan 21 nicklas 23 {
6111 29 Jan 21 nicklas 24
6111 29 Jan 21 nicklas 25   /**
6111 29 Jan 21 nicklas 26     The VariantCall raw data type.
6111 29 Jan 21 nicklas 27   */
6543 18 Jan 22 nicklas 28   public static final Rawdatatype VARIANT_CALL = new Rawdatatype("VariantCall", "variant.sequencing.variant-call", "Sequencing", Platform.SEQUENCING, "sequencing.variant-call");
6111 29 Jan 21 nicklas 29
6543 18 Jan 22 nicklas 30   /**
6543 18 Jan 22 nicklas 31     The OncoArray500K genotyping raw data type.
6543 18 Jan 22 nicklas 32     @since 1.5
6543 18 Jan 22 nicklas 33   */
6543 18 Jan 22 nicklas 34   public static final Rawdatatype ONCOARRAY500K = new Rawdatatype("OncoArray500K", "variant.genotyping.oncoarray500K", "Genotyping", "genotyping", "genotyping.oncoarray500K");
6543 18 Jan 22 nicklas 35
6111 29 Jan 21 nicklas 36   private final String rawDataTypeId;
6111 29 Jan 21 nicklas 37   private final String platformExternalId;
6111 29 Jan 21 nicklas 38   private final String variantExternalId;
6111 29 Jan 21 nicklas 39   
6111 29 Jan 21 nicklas 40   private final String name;
6111 29 Jan 21 nicklas 41   
6111 29 Jan 21 nicklas 42   private int platformId;
6543 18 Jan 22 nicklas 43   private final String platformName;
6111 29 Jan 21 nicklas 44   private int variantId;
6111 29 Jan 21 nicklas 45   
6543 18 Jan 22 nicklas 46   private Rawdatatype(String name, String id, String platformName, String platformId, String variantId)
6111 29 Jan 21 nicklas 47   {
6111 29 Jan 21 nicklas 48     this.name = name;
6111 29 Jan 21 nicklas 49     this.rawDataTypeId = id;
6543 18 Jan 22 nicklas 50     this.platformName = platformName;
6111 29 Jan 21 nicklas 51     this.platformExternalId = platformId;
6111 29 Jan 21 nicklas 52     this.variantExternalId = variantId;
6111 29 Jan 21 nicklas 53   }
6111 29 Jan 21 nicklas 54
6111 29 Jan 21 nicklas 55   public String getName()
6111 29 Jan 21 nicklas 56   {
6111 29 Jan 21 nicklas 57     return name;
6111 29 Jan 21 nicklas 58   }
6111 29 Jan 21 nicklas 59   
6543 18 Jan 22 nicklas 60   public String getPlatformName()
6543 18 Jan 22 nicklas 61   {
6543 18 Jan 22 nicklas 62     return platformName;
6543 18 Jan 22 nicklas 63   }
6543 18 Jan 22 nicklas 64
6111 29 Jan 21 nicklas 65   public String getId()
6111 29 Jan 21 nicklas 66   {
6111 29 Jan 21 nicklas 67     return rawDataTypeId;
6111 29 Jan 21 nicklas 68   }
6111 29 Jan 21 nicklas 69   
6111 29 Jan 21 nicklas 70   public String getPlatformId()
6111 29 Jan 21 nicklas 71   {
6111 29 Jan 21 nicklas 72     return platformExternalId;
6111 29 Jan 21 nicklas 73   }
6111 29 Jan 21 nicklas 74
6111 29 Jan 21 nicklas 75   public String getVariantId()
6111 29 Jan 21 nicklas 76   {
6111 29 Jan 21 nicklas 77     return variantExternalId;
6111 29 Jan 21 nicklas 78   }
6111 29 Jan 21 nicklas 79   
6111 29 Jan 21 nicklas 80   public RawDataType getRawDataType()
6111 29 Jan 21 nicklas 81   {
6111 29 Jan 21 nicklas 82     return RawDataTypes.getSafeRawDataType(rawDataTypeId);
6111 29 Jan 21 nicklas 83   }
6111 29 Jan 21 nicklas 84   
6111 29 Jan 21 nicklas 85   public Platform getPlatform(DbControl dc)
6111 29 Jan 21 nicklas 86   {
6111 29 Jan 21 nicklas 87     Platform p = null;
6111 29 Jan 21 nicklas 88     if (platformId == 0)
6111 29 Jan 21 nicklas 89     {
6111 29 Jan 21 nicklas 90        p = Platform.getByExternalId(dc, platformExternalId);
6111 29 Jan 21 nicklas 91        platformId = p.getId();
6111 29 Jan 21 nicklas 92     }
6111 29 Jan 21 nicklas 93     else
6111 29 Jan 21 nicklas 94     {
6111 29 Jan 21 nicklas 95       p = Platform.getById(dc, platformId);
6111 29 Jan 21 nicklas 96     }
6111 29 Jan 21 nicklas 97     return p;
6111 29 Jan 21 nicklas 98   }
6111 29 Jan 21 nicklas 99   
6111 29 Jan 21 nicklas 100   public PlatformVariant getVariant(DbControl dc)
6111 29 Jan 21 nicklas 101   {
6111 29 Jan 21 nicklas 102     PlatformVariant v = null;
6111 29 Jan 21 nicklas 103     if (variantId == 0)
6111 29 Jan 21 nicklas 104     {
6111 29 Jan 21 nicklas 105        v = PlatformVariant.getByExternalId(dc, variantExternalId);
6111 29 Jan 21 nicklas 106        variantId = v.getId();
6111 29 Jan 21 nicklas 107     }
6111 29 Jan 21 nicklas 108     else
6111 29 Jan 21 nicklas 109     {
6111 29 Jan 21 nicklas 110       v = PlatformVariant.getById(dc, variantId);
6111 29 Jan 21 nicklas 111     }
6111 29 Jan 21 nicklas 112     return v;
6111 29 Jan 21 nicklas 113   }
6111 29 Jan 21 nicklas 114   
6111 29 Jan 21 nicklas 115   /**
6111 29 Jan 21 nicklas 116     List all platform variants registered in BASE with an external id matching this 
6111 29 Jan 21 nicklas 117     definition. Normally, only a single item should be returned.
6111 29 Jan 21 nicklas 118   */
6111 29 Jan 21 nicklas 119   public List<PlatformVariant> list(DbControl dc)
6111 29 Jan 21 nicklas 120   {
6111 29 Jan 21 nicklas 121     ItemQuery<PlatformVariant> query = PlatformVariant.getQuery();
6111 29 Jan 21 nicklas 122     query.restrict(
6111 29 Jan 21 nicklas 123       Restrictions.eq(
6111 29 Jan 21 nicklas 124         Hql.property("externalId"), 
6111 29 Jan 21 nicklas 125         Expressions.parameter("eid", getVariantId(), Type.STRING)
6111 29 Jan 21 nicklas 126       ));
6111 29 Jan 21 nicklas 127     query.include(Include.ALL);
6111 29 Jan 21 nicklas 128     return query.list(dc);
6111 29 Jan 21 nicklas 129   }
6111 29 Jan 21 nicklas 130
6111 29 Jan 21 nicklas 131
6111 29 Jan 21 nicklas 132 }