Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added sql library for loading GFF3 to postgresql backend

  • Loading branch information...
commit e344369bbe31d12839b3d45c78937b77f7253016 1 parent 45a6710
@cybersiddhu cybersiddhu authored
Showing with 128 additions and 0 deletions.
  1. +128 −0 share/postgresql_gff3.lib
View
128 share/postgresql_gff3.lib
@@ -77,3 +77,131 @@
property text NOT NULL
)
+[insert_temp_new_feature_ids]
+ INSERT INTO temp_new_feature_ids(id)
+ SELECT tmpf.id FROM temp_feature tmpf
+ LEFT JOIN feature ON
+ tmpf.id = feature.uniquename
+ WHERE feature.uniquename is NULL
+
+[insert_new_feature]
+ INSERT INTO
+ feature(dbxref_id,type_id,organism_id,uniquename,name,residues,
+ md5checksum, seqlen)
+ SELECT tmpf.source_dbxref_id,tmpf.type_id,tmpf.organism_id,
+ tmpf.id,tmpf.name,tmpfseq.residue,tmpfseq.md5,tmpfseq.seqlen
+ FROM temp_feature tmpf
+ LEFT JOIN temp_featureseq tmpfseq ON
+ tmpf.id = tmpfseq.id
+ INNER JOIN temp_new_feature_ids ON
+ tmpf.id = temp_new_feature_ids.id
+
+[insert_new_featureloc]
+ INSERT INTO
+ featureloc(feature_id,srcfeature_id,fmin,fmax,strand,phase)
+ SELECT
+ feat.feature_id,srcfeat.feature_id,tmpfloc.start,tmpfloc.stop,
+ tmpfloc.strand,tmpfloc.phase
+ FROM temp_featureloc tmpfloc
+ INNER JOIN temp_new_feature_ids ON
+ temp_new_feature_ids.id = tmpfloc.id
+ INNER JOIN feature feat ON
+ feat.uniquename = temp_new_feature_ids.id
+ INNER JOIN feature srcfeat ON
+ srcfeat.uniquename = tmpfloc.seqid
+
+[insert_new_featureloc_target]
+ INSERT INTO
+ featureloc(feature_id,srcfeature_id,fmin,fmax,strand,phase,rank)
+ SELECT
+ feat.feature_id,srcfeat.feature_id,tmpfloc.start,tmpfloc.stop,
+ tmpfloc.strand,tmpfloc.phase,tmpfloc.rank
+ FROM temp_featureloc_target tmpfloc
+ INNER JOIN temp_new_feature_ids ON
+ temp_new_feature_ids.id = tmpfloc.id
+ INNER JOIN feature feat ON
+ feat.uniquename = temp_new_feature_ids.id
+ INNER JOIN feature srcfeat ON
+ srcfeat.uniquename = tmpfloc.seqid
+
+[insert_new_analysisfeature]
+ INSERT INTO analysisfeature(feature_id,significance,analysis_id)
+ SELECT feat.feature_id, tmpaf.score,tmpaf.analysis_id
+ FROM temp_analysisfeature tmpaf
+ INNER JOIN temp_new_feature_ids ON
+ temp_new_feature_ids.id = tmpaf.id
+ INNER JOIN feature feat ON
+ feat.uniquename = temp_new_feature_ids.id
+
+[insert_new_synonym]
+ INSERT INTO synonym(name,type_id,synonym_sgml)
+ SELECT DISTINCT tmpfs.alias,tmpfs.type_id,tmpfs.alias
+ FROM temp_feature_synonym tmpfs
+ LEFT JOIN synonym ON
+ (
+ synonym.name = tmpfs.alias
+ AND
+ synonym.type_id = tmpfs.type_id
+ )
+ WHERE
+ (
+ synonym.name is NULL
+ AND
+ synonym.type_id is NULL
+ )
+
+[insert_new_feature_synonym]
+ INSERT INTO feature_synonym(feature_id,synonym_id,pub_id)
+ SELECT feat.feature_id,syn.synonym_id,tmpfs.pub_id
+ FROM temp_feature_synonym tmpfs
+ INNER JOIN synonym syn ON
+ tmpfs.alias = syn.name
+ INNER JOIN temp_new_feature_ids ON
+ tmpfs.id = temp_new_feature_ids.id
+ INNER JOIN feature feat ON
+ temp_new_feature_ids.id = feat.uniquename
+
+[insert_new_feature_relationship]
+ INSERT into feature_relationship(object_id,subject_id,type_id)
+ SELECT pfeat.feature_id,cfeat.feature_id,tmpfr.type_id
+ FROM temp_feature_relationship tmpfr
+ INNER JOIN temp_new_feature_ids ON
+ temp_new_feature_ids.id = tmpfr.id
+ INNER JOIN feature cfeat ON
+ cfeat.uniquename = temp_new_feature_ids.id
+ INNER JOIN feature pfeat ON
+ pfeat.uniquename = tmpfr.parent_id
+
+[insert_new_dbxref]
+ INSERT INTO dbxref(accession,db_id)
+ SELECT tmpfd.dbxref,tmpfd.db_id
+ FROM temp_feature_dbxref tmpfd
+ INNER JOIN temp_new_feature_ids ON
+ temp_new_feature_ids.id = tmpfd.id
+ INNER JOIN feature ON
+ feature.uniquename = temp_new_feature_ids.id
+
+[insert_new_feature_dbxref]
+ INSERT INTO feature_dbxref(dbxref_id,feature_id)
+ SELECT dbxref.dbxref_id,feature.feature_id FROM dbxref
+ INNER JOIN temp_feature_dbxref tmpfd ON
+ (
+ dbxref.accession = tmpfd.dbxref
+ AND
+ dbxref.db_id = tmpfd.db_id
+ )
+ INNER JOIN temp_new_feature_ids ON
+ temp_new_feature_ids.id = tmpfd.id
+ INNER JOIN feature ON
+ temp_new_feature_ids.id = feature.uniquename
+
+[insert_new_featureprop]
+ INSERT INTO featureprop(feature_id,value,type_id)
+ SELECT feat.feature_id,tmpfp.property,tmpfp.type_id
+ FROM temp_featureprop tmpfp
+ INNER JOIN temp_new_feature_ids ON
+ tmpfp.id = temp_new_feature_ids.id
+ INNER JOIN feature feat ON
+ feat.uniquename = temp_new_feature_ids.id
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.