 
 
 --------------------------------------------------------------------------------
--- Name: v_pmap
+-- Name: pmap_v
 -- Purpose: summary of PMAP alignments
 -- 
 
-CREATE OR REPLACE VIEW V_PMAP AS
+CREATE OR REPLACE VIEW PMAP_V AS
 	SELECT a.params_id, a.genasm_id, h.pseq_id, ah.aln_id, min(h.pstart) AS pstart, max(h.pstop) AS pstop, count(*) AS exons, sum(h.pstop - h.pstart + 1) AS aln_length, (sum(h.pstop - h.pstart + 1)::double precision / q.len::double precision * 100::double precision)::integer AS pct_cov, a.ident, ((a.ident / sum(h.pstop - h.pstart + 1))::double precision * 100::double precision)::integer AS pct_ident, h.chr, h.plus_strand, min(h.gstart) AS gstart, max(h.gstop) AS gstop
    FROM pmap_hsp h
    JOIN pmap_alnhsp ah ON h.hsp_id = ah.hsp_id

  GROUP BY a.params_id, a.genasm_id, h.pseq_id, ah.aln_id, h.chr, h.plus_strand, a.ident, q.len
  ORDER BY h.pseq_id, (sum(h.pstop - h.pstart + 1)::double precision / q.len::double precision * 100::double precision)::integer DESC, (a.ident::double precision / sum(h.pstop - h.pstart + 1)::double precision * 100::double precision)::integer DESC;

GRANT SELECT ON V_PMAP TO PUBLIC;

-- Name: pmap.sql
-- Purpose: sql code for generating tables for storing PMAP results
--
-- $Id: pmap.sql,v 1.2 2005/11/17 17:10:51 mukhyala Exp $
-- -----------------------------------------------------------------------------

-- -----------------------------------------------------------------------------
