From: Guanming Wu <gua...@us...> - 2004-11-05 21:42:51
|
Update of /cvsroot/gmod/apollo/src/java/apollo/dataadapter/chado/jdbc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7431/apollo/src/java/apollo/dataadapter/chado/jdbc Modified Files: FlybaseChadoInstance.java Log Message: Refactoring for querying by range Index: FlybaseChadoInstance.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/chado/jdbc/FlybaseChadoInstance.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** FlybaseChadoInstance.java 3 Nov 2004 19:29:54 -0000 1.21 --- FlybaseChadoInstance.java 5 Nov 2004 21:42:37 -0000 1.22 *************** *** 48,52 **** "WHERE cdsloc.srcfeature_id = "+featLocImp.getContainingFeatureId()+" "+ "AND cdsloc.feature_id = cds.feature_id AND cds.type_id = "+protCvId+ ! "AND cds.feature_id = cds2trans.subject_id "+ "AND cds2trans.object_id = trans.feature_id "+ "AND cds2trans.type_id = "+producedByCvId+" AND trans.type_id = "+mrnaCvId+ --- 48,52 ---- "WHERE cdsloc.srcfeature_id = "+featLocImp.getContainingFeatureId()+" "+ "AND cdsloc.feature_id = cds.feature_id AND cds.type_id = "+protCvId+ ! " AND cds.feature_id = cds2trans.subject_id "+ "AND cds2trans.object_id = trans.feature_id "+ "AND cds2trans.type_id = "+producedByCvId+" AND trans.type_id = "+mrnaCvId+ *************** *** 76,80 **** private int getPaddingForTopLevelSeqType(String seqType) { if (seqType.equals("gene")) { ! if (jdbcChadoAdapter.debug) return 200; // keep small for debug return 25000; } --- 76,80 ---- private int getPaddingForTopLevelSeqType(String seqType) { if (seqType.equals("gene")) { ! if (JdbcChadoAdapter.debug) return 200; // keep small for debug return 25000; } *************** *** 113,116 **** --- 113,134 ---- return false; } + + public CurationSet getCurationSetInRange(ChadoAdapter adapter, + String seqType, + String chromosomeName, + int start, + int end, + Connection conn) { + if (conn == null) { + return null; + } + + debugPrintTime(); + // Query for the Chado feature.feature_id of the requested sequence + long seqFeatId = jdbcChadoAdapter.getFeatureId(conn, seqType, chromosomeName); + FeatureLocImplementation featLocImp = new ChromosomeFeatureLocImp(seqFeatId, start, end); + return getCurationSet(adapter, seqType, chromosomeName, featLocImp, conn); + } + /** *************** *** 127,130 **** --- 145,164 ---- debugPrintTime(); + // Query for the Chado feature.feature_id of the requested sequence + long seqFeatId = jdbcChadoAdapter.getFeatureId(conn, seqType, topFeatName); + + // padding not fully implemented - all queries need to pad - and cur set + int padding = getPaddingForTopLevelSeqType(seqType); + + FeatureLocImplementation featLocImp = + new FeatureLocImplementation(seqFeatId,haveRedundantFeatureLocs(),conn,padding); + return getCurationSet(adapter, seqType, topFeatName, featLocImp, conn); + } + + private CurationSet getCurationSet(ChadoAdapter adapter, + String seqType, + String topFeatName, + FeatureLocImplementation featLocImp, + Connection conn) { CurationSet cset = null; StrandedFeatureSet results = new StrandedFeatureSet(new FeatureSet(), new FeatureSet()); *************** *** 148,159 **** cset = new CurationSet(); ! // Query for the Chado feature.feature_id of the requested sequence ! long seqFeatId = jdbcChadoAdapter.getFeatureId(conn, seqType, topFeatName); ! ! // padding not fully implemented - all queries need to pad - and cur set ! int padding = getPaddingForTopLevelSeqType(seqType); ! ! FeatureLocImplementation featLocImp = ! new FeatureLocImplementation(seqFeatId,haveRedundantFeatureLocs(),conn,padding); adapter.fireProgressEvent(new ProgressEvent(this, new Double(50.0), "Retrieving " + seqType + " sequence " + topFeatName)); --- 182,193 ---- cset = new CurationSet(); ! // // Query for the Chado feature.feature_id of the requested sequence ! // long seqFeatId = jdbcChadoAdapter.getFeatureId(conn, seqType, topFeatName); ! // ! // // padding not fully implemented - all queries need to pad - and cur set ! // int padding = getPaddingForTopLevelSeqType(seqType); ! // ! // FeatureLocImplementation featLocImp = ! // new FeatureLocImplementation(seqFeatId,haveRedundantFeatureLocs(),conn,padding); adapter.fireProgressEvent(new ProgressEvent(this, new Double(50.0), "Retrieving " + seqType + " sequence " + topFeatName)); *************** *** 164,173 **** // gene seq has to be padded out and retrieved from parent as substring // this should be configged or something ! if (seqType.equals("gene")) { // should just take feat loc imp ! seq = jdbcChadoAdapter.getSequenceFromParent(featLocImp,true); } else { ! seq = jdbcChadoAdapter.getSequence(conn, seqFeatId, false, true); } //ChadoFeatureLoc featLoc = new ChadoFeatureLoc((int)seqFeatId,conn); --- 198,207 ---- // gene seq has to be padded out and retrieved from parent as substring // this should be configged or something ! if (seqType.equals("gene") || seqType.equals("chromosome")) { // should just take feat loc imp ! seq = jdbcChadoAdapter.getSequenceFromParent(featLocImp, true); } else { ! seq = jdbcChadoAdapter.getSequence(conn, featLocImp.getFeatureId(), false, true); } //ChadoFeatureLoc featLoc = new ChadoFeatureLoc((int)seqFeatId,conn); *************** *** 214,221 **** // Features located directly on the reference sequence // ------------------------------------------------ ! ! adapter.fireProgressEvent( ! new ProgressEvent(this, z, "Retrieving piecegenie and genscan results")); ! String[] predictionPrograms = new String[] {"genscan","piecegenie"}; if (!skipData) jdbcChadoAdapter.addGenePredictionResults(conn, predictionPrograms, results, featLocImp); --- 248,258 ---- // Features located directly on the reference sequence // ------------------------------------------------ ! String[] predictionPrograms = getPredictionPrograms(); ! //adapter.fireProgressEvent( ! // new ProgressEvent(this, z, "Retrieving piecegenie and genscan results")); ! adapter.fireProgressEvent(new ProgressEvent(this, ! z, ! "Retrieving " + concatProgramNames(predictionPrograms) + " results")); ! //String[] predictionPrograms = new String[] {"genscan","piecegenie"}; if (!skipData) jdbcChadoAdapter.addGenePredictionResults(conn, predictionPrograms, results, featLocImp); *************** *** 234,240 **** // sim4, blastx, and tblastx ! ProgressEvent p = new ProgressEvent(this, z,"Retrieving sim4 and blastx results"); adapter.fireProgressEvent(p); ! String[] hitProgs = new String[] {"sim4","%blastx%"}; if (!skipData) jdbcChadoAdapter.addSearchHits(conn, hitProgs, 0, 1, getTargetSeqs,getTgtSqSep, --- 271,281 ---- // sim4, blastx, and tblastx ! String[] hitProgs = getHitPrograms(); ! //ProgressEvent p = new ProgressEvent(this, z,"Retrieving sim4 and blastx results"); ! ProgressEvent p = new ProgressEvent(this, ! z, ! "Retrieving " + concatProgramNames(hitProgs) + " results"); adapter.fireProgressEvent(p); ! //String[] hitProgs = new String[] {"sim4","%blastx%"}; if (!skipData) jdbcChadoAdapter.addSearchHits(conn, hitProgs, 0, 1, getTargetSeqs,getTgtSqSep, *************** *** 287,290 **** --- 328,353 ---- this.jdbcChadoAdapter = jdbcAdapter; } + + protected String[] getHitPrograms() { + return new String[] {"sim4","%blastx%"}; + } + + protected String[] getPredictionPrograms() { + return new String[] {"genscan","piecegenie"}; + } + + private String concatProgramNames(String[] names) { + String msg = ""; + int size = names.length; + for (int i = 0; i < size; i++) { + msg += names[i]; + if (i < size - 2) + msg += ", "; + else if (i < size - 1) + msg += " and "; + } + return msg; + } + private void debugPrintTime() { JdbcChadoAdapter.debugPrintTime(); } } |