Skip to content
Snippets Groups Projects
FeatureLoc.xml 4.73 KiB
Newer Older
  • Learn to ignore specific revisions
  • tjc's avatar
    tjc committed
    <?xml version="1.0" encoding="UTF-8" ?> 
     
    <!DOCTYPE sqlMap 
        PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" 
        "http://ibatis.apache.org/dtd/sql-map-2.dtd"> 
     
    
    <sqlMap namespace="FeatureLoc"> 
     
         <typeAlias alias="FeatureLoc"
            type="org.gmod.schema.sequence.FeatureLoc"/>
            
    
         <resultMap id="map-location-lazy"
    
    tjc's avatar
    tjc committed
                    class="FeatureLoc">
    
    tjc's avatar
    tjc committed
    		<result property="featureByFeatureId.featureId" column="feature_id" />
    
            <result property="srcFeatureId" column="srcfeature_id" nullValue="-999" />
            <result property="featureBySrcFeatureId" column="{featureId=srcfeature_id}" 
    
    tjc's avatar
    tjc committed
                                                     select="getLazyFeatureNoResiduesById" />
    
    tjc's avatar
    tjc committed
            <result property="fmin"   column="fmin"   nullValue="-999" />
            <result property="fmax"   column="fmax"   nullValue="-999" />
            <result property="strand" column="strand" nullValue="0" />
    
    tjc's avatar
    tjc committed
            <result property="phase"  column="phase" />
    
            <result property="residueInfo" column="residue_info"/>
            <result property="locGroup"    column="locgroup"/>
            <result property="rank"        column="rank"/>
            <result property="fminPartial" column="is_fmin_partial"/>
            <result property="fmaxPartial" column="is_fmax_partial"/>
    
    tjc's avatar
    tjc committed
         </resultMap>
    
    tjc's avatar
    tjc committed
         <!--  select featureloc -->
    
         <select id="getFeatureLoc" resultMap="map-location-lazy">
    
           SELECT feature_id, srcfeature_id, fmin, fmax, strand, phase, residue_info, locgroup, rank, is_fmin_partial, is_fmax_partial
    
    tjc's avatar
    tjc committed
           FROM  featureloc
           WHERE featureloc.feature_id=#id#
         </select>
         
    
         <select id="getFeatureLocBySrcFeatureId" resultMap="map-location-lazy">
           SELECT feature_id, srcfeature_id, fmin, fmax, strand, phase, residue_info, locgroup, rank, is_fmin_partial, is_fmax_partial
           FROM  featureloc
           WHERE srcfeature_id=#id#
         </select>
         
    
    tjc's avatar
    tjc committed
    	 <select id="getFeatureLocsByListOfIds" resultMap ="map-location-lazy">
    
    	   SELECT feature_id, srcfeature_id, fmin, fmax, strand, phase, residue_info, locgroup, rank, is_fmin_partial, is_fmax_partial
    
    tjc's avatar
    tjc committed
           FROM  featureloc
           WHERE featureloc.feature_id IN <iterate open="(" close=")" conjunction=","> $[]$ </iterate>
         </select>
    	
    
         <!-- used to find match feature from the subject and query featureId -->
    
         <select id="getFeatureIdBySrcFeatureId" parameterClass="Feature" resultClass="java.lang.Integer">
            <iterate property="featureLocsForFeatureId" conjunction="INTERSECT" >
               SELECT feature_id FROM featureloc WHERE srcfeature_id=#featureLocsForFeatureId[].featureBySrcFeatureId.featureId#  
            </iterate>
         </select>
         
    
       <!--  WRITE BACK METHODS  -->
    
       <!--  UPDATE  -->
       <update id="updateFeatureLoc" 
    
    tjc's avatar
    tjc committed
                parameterClass="FeatureLoc">
          UPDATE featureloc
    
          SET fmin=$fmin$, fmax=$fmax$, strand=$strand$,
    
              is_fmin_partial=#fminPartial#,
              is_fmax_partial=#fmaxPartial#
    
    tjc's avatar
    tjc committed
          <isNotNull property="phase">
            , phase=$phase$
          </isNotNull>
          <isNull property="phase">
            , phase=NULL
          </isNull>
    
    tjc's avatar
    tjc committed
          WHERE
    
          <isGreaterThan property="featureByFeatureId.featureId" compareValue="0">
            feature_id=$featureByFeatureId.featureId$
          </isGreaterThan>
          <isLessEqual property="featureByFeatureId.featureId" compareValue="0">
             <isNotNull property="featureByFeatureId.uniqueName">
               feature_id=(SELECT feature_id FROM feature WHERE uniquename=#featureByFeatureId.uniqueName#)
             </isNotNull>
          </isLessEqual>
          <isGreaterThan property="featureBySrcFeatureId.featureId" compareValue="0" prepend="AND">
            srcfeature_id=$featureBySrcFeatureId.featureId$
          </isGreaterThan>
       </update>
    
    tjc's avatar
    tjc committed
       
       <update id="updateFeatureLocByChangingSequence" 
                parameterClass="uk.ac.sanger.artemis.chado.FeatureForUpdatingResidues">
          UPDATE featureloc
          SET 
           <isNotNull property="newSubSequence">
             fmin=fmin+$length$, fmax=fmax+$length$
           </isNotNull>
           <isNull property="newSubSequence">
             fmin=fmin-$length$, fmax=fmax-$length$
           </isNull>
          WHERE fmin >= $startBase$ AND srcfeature_id=$featureId$
    
    tjc's avatar
    tjc committed
        </update>
       
        <insert id="insertFeatureLoc" 
    
    tjc's avatar
    tjc committed
                parameterClass="FeatureLoc">
    
    tjc's avatar
    tjc committed
          INSERT INTO featureloc
    
    tjc's avatar
    tjc committed
            ( featureloc_id, feature_id, srcfeature_id, fmin, fmax, strand, rank
              <isNotNull property="phase">
    
    tjc's avatar
    tjc committed
               , phase
              </isNotNull> 
            )
          VALUES
            ( nextval('featureloc_featureloc_id_seq'),
    
    tjc's avatar
    tjc committed
              $featureByFeatureId.featureId$,
              $featureBySrcFeatureId.featureId$,
              $fmin$,
              $fmax$,
              $strand$,
              $rank$
              <isNotNull property="phase">
                , $phase$
    
    tjc's avatar
    tjc committed
              </isNotNull>
            )
        </insert>
             
    </sqlMap>