Update of /cvsroot/gmod/apollo/src/java/apollo/dataadapter/organism In directory sc8-pr-cvs1:/tmp/cvs-serv18105/apollo/dataadapter/organism Modified Files: ApolloNameAdapterI.java DefaultNameAdapter.java FlyNameAdapter.java FlyOverlap.java HumanOverlap.java Log Message: This is a sizable commit, but still needs further debugging. The biggest changes are the removal of GenericAnnotations, which have been replaced by AnnotatedFeatures. These do what Mark has long advocated: the FeatureSet is at the top and SeqFeatures inherit from them. Didn't do it for everything, only annotated features. This means that an Exon is now a 'set', but one that can never have child features. I tried to find most of the bugs due to set methods being called instead of the more appropriate non-set methods, but there are likely still to be more lurking. Be on the look-out for problems that might be called due to this change. All-in-all I like this new way of doing things and think we should consider it for all of the features. Another thing to look out for is misinterpreted casting, since Gene as a class is no longer there it takes actual code to determine if the AnnotatedFeature is at the top or is a Transcript/Exon. In addition fixed 2 small other bugs. 1. the annotation tree panel is up again 2. <ctrl>c and <ctrl>e no longer throw array out of bounds exception Index: ApolloNameAdapterI.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/organism/ApolloNameAdapterI.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ApolloNameAdapterI.java 18 Dec 2003 17:33:09 -0000 1.12 --- ApolloNameAdapterI.java 31 Dec 2003 23:24:35 -0000 1.13 *************** *** 19,22 **** --- 19,28 ---- public void setName(SeqFeatureI feature, String name); + // sets the name of a feature based upon its parent + public void setName(Transcript transcript, AnnotatedFeatureI gene); + + // sets the name of a derived sequences based upon transcript name + public void changeSeqNames(Transcript transcript); + //find out if name is an id string public boolean nameIsId (SeqFeatureI feature); *************** *** 29,37 **** //generates a name for a given feature ! public String selectMergeName(Gene feature1, Gene feature2); //generates a URL ! //public String generateURL (Gene g); ! public String generateURL (GenericAnnotationI g); // get the display name of a seqfeature --- 35,43 ---- //generates a name for a given feature ! public String selectMergeName(AnnotatedFeatureI feature1, ! AnnotatedFeatureI feature2); //generates a URL ! public String generateURL (AnnotatedFeatureI g); // get the display name of a seqfeature Index: DefaultNameAdapter.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/organism/DefaultNameAdapter.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** DefaultNameAdapter.java 20 Dec 2003 01:16:39 -0000 1.16 --- DefaultNameAdapter.java 31 Dec 2003 23:24:35 -0000 1.17 *************** *** 22,27 **** //generates a name for a given feature public String generateName(SeqFeatureI feature) { ! if (feature instanceof Gene) { ! return getName(Gene.class, geneNumber, "GN", ""); } else if (feature instanceof Transcript) { return getName (Transcript.class, transcriptNumber, "XS", ""); --- 22,27 ---- //generates a name for a given feature public String generateName(SeqFeatureI feature) { ! if (feature instanceof AnnotatedFeature) { ! return getName(AnnotatedFeature.class, geneNumber, "GN", ""); } else if (feature instanceof Transcript) { return getName (Transcript.class, transcriptNumber, "XS", ""); *************** *** 34,39 **** //generates a ID for a given feature public String generateId(SeqFeatureI feature) { ! if (feature instanceof Gene) { ! return getId (Gene.class, geneNumber, "GN", ""); } else if (feature instanceof Transcript) { return getId(Transcript.class, transcriptNumber, "XS", ""); --- 34,39 ---- //generates a ID for a given feature public String generateId(SeqFeatureI feature) { ! if (feature instanceof AnnotatedFeature) { ! return getId (AnnotatedFeature.class, geneNumber, "GN", ""); } else if (feature instanceof Transcript) { return getId(Transcript.class, transcriptNumber, "XS", ""); *************** *** 48,56 **** } //generates a ID for a given feature public boolean nameIsId (SeqFeatureI feature) { String prefix; ! if (feature instanceof Gene) { prefix = "GN"; } else if (feature instanceof Transcript) { --- 48,67 ---- } + public void setName(Transcript feature, AnnotatedFeatureI gene) { + feature.setName(gene.getName()); + } + + public void changeSeqNames(Transcript t) { + if (t.get_cDNASequence() != null) + t.get_cDNASequence().setAccessionNo(t.getName()); + if (t.getPeptideSequence() != null) { + t.getPeptideSequence().setAccessionNo(t.getName()); + } + } //generates a ID for a given feature public boolean nameIsId (SeqFeatureI feature) { String prefix; ! if (feature instanceof AnnotatedFeature) { prefix = "GN"; } else if (feature instanceof Transcript) { *************** *** 119,123 **** } ! public String generateURL (GenericAnnotationI g) { return null; } --- 130,134 ---- } ! public String generateURL (AnnotatedFeatureI g) { return null; } *************** *** 133,137 **** } ! public String selectMergeName (Gene feature1, Gene feature2) { String chosen_name = feature1.getName(); return chosen_name; --- 144,149 ---- } ! public String selectMergeName (AnnotatedFeatureI feature1, ! AnnotatedFeatureI feature2) { String chosen_name = feature1.getName(); return chosen_name; *************** *** 144,155 **** // This isn't terrible, but it seems like a waste of time. // I'm not sure why it's getting called so much. - // System.out.println("DefaultNameAdapter:getDisplayName: display_name = " + display_name + " for feature " + sf); // DEL if ( display_name.equals(Range.NO_NAME) && ! (sf instanceof FeatureSetI) && ! ! (sf instanceof GenericAnnotationSet) ! ) { FeatureSetI fs = (FeatureSetI) sf; - sf = fs.getFeatureAt(0); display_name = fs.getFeatureAt(0).getName(); --- 156,163 ---- // This isn't terrible, but it seems like a waste of time. // I'm not sure why it's getting called so much. if ( display_name.equals(Range.NO_NAME) && ! (sf instanceof FeatureSetI) && ! (sf instanceof AnnotatedFeatureI)) { FeatureSetI fs = (FeatureSetI) sf; sf = fs.getFeatureAt(0); display_name = fs.getFeatureAt(0).getName(); *************** *** 200,204 **** public String peptideName(String name) { ! return name; // Don't do anything to it (not sure if there should be a general rule) } --- 208,213 ---- public String peptideName(String name) { ! // Don't do anything to it (not sure if there should be a general rule) ! return name; } *************** *** 214,221 **** if (sf instanceof ExonI) { - // System.out.print("exon "); ExonI exon = (ExonI)sf; ! if (exon.getTranscript() != null) { ! name = exon.getTranscript().getName(); } else { System.out.println("WARNING: No transcript for exon " + --- 223,229 ---- if (sf instanceof ExonI) { ExonI exon = (ExonI)sf; ! if (exon.getRefFeature() != null) { ! name = exon.getRefFeature().getName(); } else { System.out.println("WARNING: No transcript for exon " + Index: FlyNameAdapter.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/organism/FlyNameAdapter.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** FlyNameAdapter.java 18 Dec 2003 17:33:09 -0000 1.22 --- FlyNameAdapter.java 31 Dec 2003 23:24:35 -0000 1.23 *************** *** 17,36 **** /** Current format of dates in FASTA header lines for Drosophila, e.g. ! * >gi||gb|AB003910|AB003910 Fruitfly DNA for 88F actin, complete cds. (08-JUN-1999) ! * Should this format be defined in game.style? Or maybe we could figure out the ! * date format from the dates themselves?? */ ! private static SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); ! ! ! /** generates a name for a given feature - this only works for ! genes, transcripts and exons */ public String generateName(SeqFeatureI feature) { ! if (feature instanceof Gene) { ! return getGeneName((Gene) feature); } else if (feature instanceof Transcript) { return getTransName ((Transcript) feature); ! } else if (feature instanceof ExonI) { ! int num = getNameCount (ExonI.class, exonNumber, "EX"); ! return "EX:temp"+(num); } else return "???"; --- 17,34 ---- /** Current format of dates in FASTA header lines for Drosophila, e.g. ! * >gi||gb|AB003910|AB003910 Fruitfly DNA for 88F actin, complete cds. ! * (08-JUN-1999) ! * Should this format be defined in game.style? ! * Or maybe we could figure out the date format from the dates themselves?? ! * generates a name for a given feature - this only works for ! genes, transcripts and exons */ public String generateName(SeqFeatureI feature) { ! if (feature instanceof ExonI) { ! int num = getNameCount (ExonI.class, exonNumber, "EX"); ! return "EX:temp"+(num); } else if (feature instanceof Transcript) { return getTransName ((Transcript) feature); ! } else if (feature instanceof AnnotatedFeature) { ! return getGeneName((AnnotatedFeature) feature); } else return "???"; *************** *** 39,54 **** //generates a ID for a given feature public String generateId(SeqFeatureI feature) { ! if (feature instanceof Gene) { ! if ((feature.getId() != null && ! feature.getId().startsWith ("CR")) || ! (feature.getName() != null && ! feature.getName().startsWith("CR"))) ! return getId (Gene.class, geneNumber, "CR", ""); ! else ! return getId (Gene.class, geneNumber, "CG", ""); } else if (feature instanceof Transcript) { return getId(Transcript.class, transcriptNumber, "CT", ""); ! } else if (feature instanceof ExonI) { ! return getId(ExonI.class, exonNumber, "EX", ""); } else return "???"; --- 37,52 ---- //generates a ID for a given feature public String generateId(SeqFeatureI feature) { ! if (feature instanceof ExonI) { ! return getId(ExonI.class, exonNumber, "EX", ""); } else if (feature instanceof Transcript) { return getId(Transcript.class, transcriptNumber, "CT", ""); ! } else if (feature instanceof AnnotatedFeature) { ! if ((feature.getId() != null && ! feature.getId().startsWith ("CR")) || ! (feature.getName() != null && ! feature.getName().startsWith("CR"))) ! return getId (AnnotatedFeature.class, geneNumber, "CR", ""); ! else ! return getId (AnnotatedFeature.class, geneNumber, "CG", ""); } else return "???"; *************** *** 56,103 **** public String getDisplayName (SeqFeatureI sf) { ! // System.out.println("FNA.getDisplayName: getting name for " + sf.getClass().getName() + " " + sf.getName()); // DEL ! return sf.getName(); } ! // This is used for making labels in the display. The result names are too long, ! // e.g. AY058300-AE003603.Sept-na_gb.dros, when what we want is just AY085300. ! // !! I'd like the labels to look like the names made by SetDetailPanel.setupHeader ! // but can't just directly use that method, because it has access to a FeatureSet ! // as well as a SeqFeature. Need to make this work. ! // For now, using a kludge to shorten the names. public String getShortName (SeqFeatureI sf) { String name = getDisplayName(sf); - // Not working right - // if (sf instanceof FeaturePair) { - // // SequenceI seq = fset.getAlignmentSequence(); - // SeqFeatureI hit = ((FeaturePair)sf).getHitFeature(); - // SequenceI seq = hit.getRefSequence(); - // System.out.println("getShortName(" + name + "): hit = " + hit + ", seq = " + seq); // DEL - // if (seq == null) { - // seq = ((FeaturePair)sf).getRefSequence(); - // } - // if (seq != null) { - // name = seq.getDisplayId() != null ? seq.getDisplayId() : ""; - // } else { - // name = hit.getName() != null ? hit.getName() : ""; - // } - // } - // else { - // SequenceI seq = sf.getRefSequence(); - // SeqFeatureI feat = sf.getRefFeature(); - // System.out.println("getShortName(" + name + "): seq = " + seq); // DEL - // if (seq == null) { - // seq = feat.getRefSequence(); - // System.out.println("getShortName(" + name + "): ref feature = " + feat + ", seq = " + seq); // DEL - // } - // if (seq != null) { - // name = seq.getDisplayId() != null ? seq.getDisplayId() : ""; - // } else { - // name = feat.getName() != null ? feat.getName() : ""; - // } - // } - - // This is a kludge to make the name shorter by chopping off unnecessary pieces if (name.length() > 12) { if (name.indexOf("-") > 5) --- 54,78 ---- public String getDisplayName (SeqFeatureI sf) { ! if (sf instanceof ExonI) { ! Transcript transcript = ((ExonI) sf).getTranscript(); ! return (transcript.getName() + ! " exon " + (transcript.getFeatureIndex(sf) + 1)); ! } ! else ! return sf.getName(); } ! /** This is used for making labels in the display. ! The result names are too long, ! e.g. AY058300-AE003603.Sept-na_gb.dros, when what we want is ! just AY085300. ! !! I'd like the labels to look like the names made by ! SetDetailPanel.setupHeader ! but can't just directly use that method, because it has access ! to a FeatureSet as well as a SeqFeature. Need to make this work. ! For now, using a kludge to shorten the names. */ public String getShortName (SeqFeatureI sf) { String name = getDisplayName(sf); if (name.length() > 12) { if (name.indexOf("-") > 5) *************** *** 115,128 **** name = name.substring(0, name.lastIndexOf("-")); } - - // System.out.println("getShortName: short name for " + getDisplayName(sf) + " is " + name); // DEL return name; } public void setName (SeqFeatureI sf, String name) { ! if (sf instanceof Gene) { if ((name.startsWith("CR")) || (name.startsWith("CG"))) { if ((sf.getId() != null) && (!sf.getId().equals(name))) { ! ((Gene) sf).addSynonym(sf.getId()); } sf.setId(name); --- 90,101 ---- name = name.substring(0, name.lastIndexOf("-")); } return name; } public void setName (SeqFeatureI sf, String name) { ! if (!(sf instanceof Transcript) && !(sf instanceof ExonI)){ if ((name.startsWith("CR")) || (name.startsWith("CG"))) { if ((sf.getId() != null) && (!sf.getId().equals(name))) { ! ((AnnotatedFeatureI) sf).addSynonym(sf.getId()); } sf.setId(name); *************** *** 135,143 **** public String getHeader (SeqFeatureI sf) { if (sf instanceof FeaturePair) { - // System.out.println("display id for " + sf + " (class " + sf.getClass().getName() + ") is " + ((FeaturePair)sf).getDisplayId()); // DEL return ((FeaturePair)sf).getDisplayId(); } else { ! // System.out.println("display name for " + sf + " (class " + sf.getClass().getName() + ") is " + sf.getName()); // DEL ! return sf.getName(); } } --- 108,114 ---- public String getHeader (SeqFeatureI sf) { if (sf instanceof FeaturePair) { return ((FeaturePair)sf).getDisplayId(); } else { ! return getDisplayName(sf); } } *************** *** 147,157 **** String prefix; boolean is_ID = false; ! if (feature instanceof Gene) { ! prefix = "CG"; is_ID = (getCG (feature.getName(), prefix) != null || feature.getName().startsWith (prefix+":temp") || (feature.getName().startsWith (prefix) && feature.getName().indexOf ("tmp") > 0)); ! prefix = "CR"; } else if (feature instanceof Transcript) { prefix = "CT"; --- 118,128 ---- String prefix; boolean is_ID = false; ! if (feature instanceof ExonI) { ! prefix = "EX"; is_ID = (getCG (feature.getName(), prefix) != null || feature.getName().startsWith (prefix+":temp") || (feature.getName().startsWith (prefix) && feature.getName().indexOf ("tmp") > 0)); ! prefix = "CG"; } else if (feature instanceof Transcript) { prefix = "CT"; *************** *** 161,171 **** feature.getName().indexOf ("tmp") > 0)); prefix = "CG"; ! } else if (feature instanceof ExonI) { ! prefix = "EX"; is_ID = (getCG (feature.getName(), prefix) != null || feature.getName().startsWith (prefix+":temp") || (feature.getName().startsWith (prefix) && feature.getName().indexOf ("tmp") > 0)); ! prefix = "CG"; } else prefix = "???"; --- 132,142 ---- feature.getName().indexOf ("tmp") > 0)); prefix = "CG"; ! } else if (feature instanceof AnnotatedFeature) { ! prefix = "CG"; is_ID = (getCG (feature.getName(), prefix) != null || feature.getName().startsWith (prefix+":temp") || (feature.getName().startsWith (prefix) && feature.getName().indexOf ("tmp") > 0)); ! prefix = "CR"; } else prefix = "???"; *************** *** 184,190 **** prefix = prefix + ":temp"; Vector features ! = SeqFeatureUtil.getFeaturesOfClass(curationSet.getAnnots(), ! featureClass, ! false); int num = start; for(int i=0; i < features.size(); i++) { --- 155,161 ---- prefix = prefix + ":temp"; Vector features ! = SeqFeatureUtil.getFeaturesOfClass(curationSet.getAnnots(), ! featureClass, ! false); int num = start; for(int i=0; i < features.size(); i++) { *************** *** 210,275 **** int start, String prefix) { ! Vector features ! = SeqFeatureUtil.getFeaturesOfClass(curationSet.getAnnots(), ! featureClass, ! false); ! int num = start; ! for(int i=0; i < features.size(); i++) { ! SeqFeatureI g = (SeqFeatureI) features.elementAt(i); ! String this_name = g.getName(); ! if (this_name.startsWith(prefix)) { ! try { ! // check for any temp in the name ! int index = this_name.indexOf (":temp"); ! String num_str; ! // then parse out the count from the name ! if (index > 0) ! num_str = this_name.substring (index + ":temp".length()); ! else { ! index = this_name.indexOf (":"); ! if (index > 0) ! num_str = this_name.substring (index + 1); ! else ! num_str = this_name.substring(prefix.length()); ! } ! // System.out.println ("Checking " + num_str + ! // " in " + this_name); ! int namenum = Integer.parseInt(num_str); ! if (namenum >= num) { ! num = namenum + 1; ! } ! } catch (NumberFormatException e) {} ! } } ! return num; } ! private String getGeneName (Gene feature) { ! String gene_name = feature.getName(); ! if (gene_name.equals (SeqFeatureI.NO_NAME) || ! gene_name.startsWith ("CG")) ! return getId (Gene.class, geneNumber, "CG", ""); ! else if (gene_name.startsWith ("CR")) ! return getId (Gene.class, geneNumber, "CR", ""); ! else { ! int index = gene_name.lastIndexOf (":"); ! if (index > 0 && (index + 1) < gene_name.length()) { ! // then parse out the count from the name ! String num_str = gene_name.substring(index + 1); ! try { ! int namenum = Integer.parseInt(num_str); ! gene_name = gene_name.substring (0, index); ! // System.out.println ("Gene prefix is " + gene_name); ! } catch (NumberFormatException e) {} ! } ! int num = getNameCount (Gene.class, 1, gene_name); ! return gene_name+":"+(num); ! } } private String getTransName (Transcript feature) { ! Gene gene = feature.getGene(); ! Vector transcripts = gene.getTranscripts(); int t_index = transcripts.indexOf (feature); String new_name; --- 181,245 ---- int start, String prefix) { ! Vector features ! = SeqFeatureUtil.getFeaturesOfClass(curationSet.getAnnots(), ! featureClass, ! false); ! int num = start; ! for(int i=0; i < features.size(); i++) { ! SeqFeatureI g = (SeqFeatureI) features.elementAt(i); ! String this_name = g.getName(); ! if (this_name.startsWith(prefix)) { ! try { ! // check for any temp in the name ! int index = this_name.indexOf (":temp"); ! String num_str; ! // then parse out the count from the name ! if (index > 0) ! num_str = this_name.substring (index + ":temp".length()); ! else { ! index = this_name.indexOf (":"); ! if (index > 0) ! num_str = this_name.substring (index + 1); ! else ! num_str = this_name.substring(prefix.length()); ! } ! // System.out.println ("Checking " + num_str + ! // " in " + this_name); ! int namenum = Integer.parseInt(num_str); ! if (namenum >= num) { ! num = namenum + 1; ! } ! } catch (NumberFormatException e) {} } ! } ! return num; } ! private String getGeneName (AnnotatedFeatureI feature) { ! String gene_name = feature.getName(); ! if (gene_name.equals (SeqFeatureI.NO_NAME) || ! gene_name.startsWith ("CG")) ! return getId (AnnotatedFeature.class, geneNumber, "CG", ""); ! else if (gene_name.startsWith ("CR")) ! return getId (AnnotatedFeature.class, geneNumber, "CR", ""); ! else { ! int index = gene_name.lastIndexOf (":"); ! if (index > 0 && (index + 1) < gene_name.length()) { ! // then parse out the count from the name ! String num_str = gene_name.substring(index + 1); ! try { ! int namenum = Integer.parseInt(num_str); ! gene_name = gene_name.substring (0, index); ! } catch (NumberFormatException e) {} ! } ! int num = getNameCount (AnnotatedFeature.class, 1, gene_name); ! return gene_name+":"+(num); } + } private String getTransName (Transcript feature) { ! AnnotatedFeatureI gene = feature.getGene(); ! Vector transcripts = gene.getFeatures(); int t_index = transcripts.indexOf (feature); String new_name; *************** *** 289,292 **** --- 259,308 ---- } + /* 12/08/2003: + Transcript names (symbols) should inherit from parent annotation symbol, + not parent annotation ID. + Transcript ID (passed as argument) is used only for its *suffix*-- + prefix is ignored. */ + public void setName(Transcript t, AnnotatedFeatureI gene) { + // And what if it isn't? Then what?? + String transcript_name; + String transcript_id = t.getId(); + int index = (transcript_id != null ? + transcript_id.lastIndexOf("-") : -1); + if (index > 0) { + transcript_name=(gene.getName() + transcript_id.substring(index)); + } + else { + transcript_name=(gene.getName() + + getNewSuffix(gene.getFeatureIndex(t), + gene.getFeatures())); + } + if (t.getName() == null || + (t.getName() != null && !t.getName().equals(transcript_name))) { + t.setName(transcript_name); + // When transcript name is changed, change cDNA and peptide names also + changeSeqNames(t); + } + } + + // Set the cDNA *and* peptide names based on the new transcript name. + public void changeSeqNames(Transcript t) { + if (t.get_cDNASequence() != null) + t.get_cDNASequence().setAccessionNo(t.getName()); + if (t.getPeptideSequence() != null) { + t.getPeptideSequence().setAccessionNo(peptideName(t.getName())); + } + } + + // Convert a cdna name to a peptide name by changing -R to -P, e.g. + // CG123-RA -> CG123-PA + public String peptideName(String name) { + if (name.indexOf("-R") > 0) { + name = name.substring(0, name.indexOf("-R")+1) + "P" + + name.substring(name.indexOf("-R") + 2); + } + return name; + } + // Construct a new index for transcript #t_index, following the // pattern -RA, -RB, ..., -RAA, -RAB, ... -RZZ *************** *** 301,315 **** letter = (char)('A' + div26); suffix = suffix + letter; - // System.out.println("t_index > 26. t_index = " + t_index + ", div26 = " + div26 + ", letter = " + letter + ", suffix = " + suffix); } int remainder = t_index % 26; letter = (char)('A' + remainder); suffix = suffix + letter; - // System.out.println("Out of loop, num transcripts = " + transcripts.size() + ", t_index = " + t_index + ", remainder = " + remainder + ", letter = " + letter + ", now suffix = " + suffix); - suffix = "-R" + suffix; // make sure it is unique if (suffixInUse (transcripts, suffix, t_index)) { - // System.out.println("Suffix in use: " + suffix + "--recursively calling getNewSuffix(" + t_index +"+1)"); // If that suffix was used, recursively choose a new one. return(getNewSuffix(t_index+1, transcripts)); --- 317,327 ---- *************** *** 318,322 **** } ! public String generateURL (GenericAnnotationI g) { Hashtable id_hash = new Hashtable(); --- 330,334 ---- } ! public String generateURL (AnnotatedFeatureI g) { Hashtable id_hash = new Hashtable(); *************** *** 342,348 **** id_hash.put (id, id); else { ! id = getCG ((String) g.getSynonyms().elementAt(i), "CR"); ! if (id != null) ! id_hash.put (id, id); } } --- 354,360 ---- id_hash.put (id, id); else { ! id = getCG ((String) g.getSynonyms().elementAt(i), "CR"); ! if (id != null) ! id_hash.put (id, id); } } *************** *** 352,358 **** id_hash.put (id, id); else { ! id = getCG (g.getName(), "CR"); ! if (id != null) ! id_hash.put (id, id); } --- 364,370 ---- id_hash.put (id, id); else { ! id = getCG (g.getName(), "CR"); ! if (id != null) ! id_hash.put (id, id); } *************** *** 361,371 **** id_hash.put (id, id); else { ! id = getCG (g.getId(), "CR"); ! if (id != null) ! id_hash.put (id, id); } ! // The code here was glomming together all the elements into one big |ed string, ! // but that's not what the gene report CGI wants. An FBgn or CG should be sufficient. StringBuffer query_str = new StringBuffer(); for (Enumeration e = id_hash.elements() ; --- 373,384 ---- id_hash.put (id, id); else { ! id = getCG (g.getId(), "CR"); ! if (id != null) ! id_hash.put (id, id); } ! // The code here was glomming together all the elements into one ! // big |ed string, but that's not what the gene report CGI wants. ! // An FBgn or CG should be sufficient. StringBuffer query_str = new StringBuffer(); for (Enumeration e = id_hash.elements() ; *************** *** 432,467 **** } ! public String selectMergeName (Gene feature1, Gene feature2) { ! String chosen_name = feature1.getName(); ! String name1 = feature1.getName(); ! String name2 = feature2.getName(); ! if (name1.equals (SeqFeatureI.NO_NAME)) ! name1 = "CG"; ! if (name2.equals (SeqFeatureI.NO_NAME)) ! name2 = "CG"; ! // If one of them has "temp" in its name, that is never the right choice-- ! // pick the other one. ! if (name2.indexOf (":temp") >= 0) ! return name1; ! else if (name1.indexOf (":temp") >= 0) ! return name2; ! if ((name1.startsWith ("CG") && name2.startsWith ("CG")) || ! (name1.startsWith ("CG") && name2.startsWith ("CR")) || ! (name1.startsWith ("CR") && name2.startsWith ("CG"))) { ! chosen_name = getId (Gene.class, geneNumber, "CG", ""); ! } ! else if (name1.startsWith ("CR") && name2.startsWith ("CR")) { ! chosen_name = getId (Gene.class, geneNumber, "CR", ""); ! } ! else if (name1.startsWith ("CG") || name1.startsWith("CR")) { ! chosen_name = name2; ! } ! else if (name2.startsWith ("CG") || name2.startsWith("CR")) { ! chosen_name = name1; ! } ! else { // Cambridge has to decide these based on date // precedence (Can this be inferred from FBgn?) --- 445,481 ---- } ! public String selectMergeName (AnnotatedFeatureI feature1, ! AnnotatedFeatureI feature2) { ! String chosen_name = feature1.getName(); ! String name1 = feature1.getName(); ! String name2 = feature2.getName(); ! if (name1.equals (SeqFeatureI.NO_NAME)) ! name1 = "CG"; ! if (name2.equals (SeqFeatureI.NO_NAME)) ! name2 = "CG"; ! // If one of them has "temp" in its name, that is never the right choice-- ! // pick the other one. ! if (name2.indexOf (":temp") >= 0) ! return name1; ! else if (name1.indexOf (":temp") >= 0) ! return name2; ! if ((name1.startsWith ("CG") && name2.startsWith ("CG")) || ! (name1.startsWith ("CG") && name2.startsWith ("CR")) || ! (name1.startsWith ("CR") && name2.startsWith ("CG"))) { ! chosen_name = getId (AnnotatedFeature.class, geneNumber, "CG", ""); ! } ! else if (name1.startsWith ("CR") && name2.startsWith ("CR")) { ! chosen_name = getId (AnnotatedFeature.class, geneNumber, "CR", ""); ! } ! else if (name1.startsWith ("CG") || name1.startsWith("CR")) { ! chosen_name = name2; ! } ! else if (name2.startsWith ("CG") || name2.startsWith("CR")) { ! chosen_name = name1; ! } ! else { // Cambridge has to decide these based on date // precedence (Can this be inferred from FBgn?) *************** *** 473,477 **** String id1 = xref1.getIdValue(); String id2 = xref1.getIdValue(); ! if (id1 != null && id2 != null && id1.startsWith ("FBgn") && id2.startsWith ("FBgn")) { id1 = id1.substring ("FBgn".length()); id2 = id2.substring ("FBgn".length()); --- 487,494 ---- String id1 = xref1.getIdValue(); String id2 = xref1.getIdValue(); ! if (id1 != null && ! id2 != null && ! id1.startsWith ("FBgn") && ! id2.startsWith ("FBgn")) { id1 = id1.substring ("FBgn".length()); id2 = id2.substring ("FBgn".length()); *************** *** 510,524 **** public String getBioTypeForDisplay(SeqFeatureI sf) { - // String type = sf.getBioType(); - // // capitalize it - // type = capitalize(type); - // if (!type.equalsIgnoreCase("Transcript")) return type; - // String parentType = sf.getRefFeature().getType(); - // // should this be Gene type? - // if (parentType.equalsIgnoreCase("gene")) return type; - // if (!parentType.equalsIgnoreCase("tRNA")) parentType = capitalize(parentType); - // // should it just be parentType? - // return parentType + " " + type; - String typeDisplay = sf.getBioType(); typeDisplay = capitalize(typeDisplay); --- 527,530 ---- *************** *** 536,554 **** } ! // Convert a cdna name to a peptide name by changing -R to -P, e.g. ! // CG123-RA -> CG123-PA ! public String peptideName(String name) { ! if (name.indexOf("-R") > 0) { ! // System.out.println("peptideName: changing " + name + " to "); // DEL ! name = name.substring(0, name.indexOf("-R")+1) + "P" + name.substring(name.indexOf("-R") + 2); ! // System.out.println(" " + name); // DEL ! } ! return name; ! } ! ! // Given a FASTA-style header line, extract the date. ! // For fly sequences, the expected format of the header line is ! // >gi||gb|AB003910|AB003910 Fruitfly DNA for 88F actin, complete cds. (08-JUN-1999) ! // Date is that thing at the end, obviously. public Date getDateFromHeader(String header) { Date date = null; --- 542,559 ---- } ! /** Given a FASTA-style header line, extract the date. ! * For fly sequences, the expected format of the header line is ! * >gi||gb|AB003910|AB003910 Fruitfly DNA for 88F actin, complete cds. ! * (08-JUN-1999) ! * Date is that thing at the end, obviously. ! * Using the expected dateFormat (defined near the top of this file) ! * parse the date string and return it as a Date object. ! * People need to educate themselves about what is already available ! * in the code and stop reinventing things. Apollo will be impossible ! * to maintain otherwise. Look around first and either reuse existing ! * coding or consilidate common bits before re-writing anything. ! * I changed this to use Apollo.util.DateUtil SUZ ! */ ! public Date getDateFromHeader(String header) { Date date = null; *************** *** 562,589 **** if (possibleDate.indexOf(")") >= 0) possibleDate = possibleDate.substring(0, possibleDate.indexOf(")")); ! date = parseDate(possibleDate); } return date; } - /** Using the expected dateFormat (defined near the top of this file) - * parse the date string and return it as a Date object. */ - public Date parseDate(String dateString) { - try { - Date date = dateFormat.parse(dateString); - // System.out.println("Style.parseDate: parsed dateString " + dateString + ": " + date); // DEL - return date; - } - catch (Exception e) { - // System.out.println("Style.parseDate: couldn't parse date string " + dateString + ": " + e); // DEL - return null; - } - } - // Returns true if the date in the description is newer than date2. public boolean isNewerThan(String description, Date date2) { Date date1 = getDateFromHeader(description); - // System.out.println("FlyNameAdapter.isNewerThan(" + description + ", " + date2 + ") = " + - // isNewerThan(date1, date2)); // DEL return(isNewerThan(date1, date2)); } --- 567,578 ---- if (possibleDate.indexOf(")") >= 0) possibleDate = possibleDate.substring(0, possibleDate.indexOf(")")); ! date = DateUtil.makeADate(possibleDate); } return date; } // Returns true if the date in the description is newer than date2. public boolean isNewerThan(String description, Date date2) { Date date1 = getDateFromHeader(description); return(isNewerThan(date1, date2)); } *************** *** 593,604 **** if (date1 == null || date2 == null) return false; ! return (date2.compareTo(date1) <= 0); ! } ! ! /** The opposite of parseDate: converts a Date object to a String in ! * the current format. (This is needed in case the user wants to change the ! * tiers and save as a tiers file.) */ ! public String formatDate(Date date) { ! return dateFormat.format(date); } --- 582,587 ---- if (date1 == null || date2 == null) return false; ! else ! return (date2.compareTo(date1) <= 0); } Index: FlyOverlap.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/organism/FlyOverlap.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FlyOverlap.java 5 Dec 2003 22:34:45 -0000 1.4 --- FlyOverlap.java 31 Dec 2003 23:24:35 -0000 1.5 *************** *** 14,18 **** public boolean areOverlapping(SeqFeatureI sa,SeqFeatureI sb) { boolean overlap = false; ! if (sb instanceof FeatureSetI) { FeatureSetI fb = (FeatureSetI)sb; for (int i=0; i<fb.size() && !overlap; i++) { --- 14,18 ---- public boolean areOverlapping(SeqFeatureI sa,SeqFeatureI sb) { boolean overlap = false; ! if (sb.canHaveChildren()) { FeatureSetI fb = (FeatureSetI)sb; for (int i=0; i<fb.size() && !overlap; i++) { *************** *** 20,24 **** } } ! else if (sa instanceof FeatureSetI) { FeatureSetI fa = (FeatureSetI)sa; for (int i=0; i<fa.size() && !overlap; i++) { --- 20,24 ---- } } ! else if (sa.canHaveChildren()) { FeatureSetI fa = (FeatureSetI)sa; for (int i=0; i<fa.size() && !overlap; i++) { Index: HumanOverlap.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/organism/HumanOverlap.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HumanOverlap.java 23 Nov 2002 16:18:22 -0000 1.1 --- HumanOverlap.java 31 Dec 2003 23:24:35 -0000 1.2 *************** *** 18,22 **** public boolean areOverlapping(SeqFeatureI sa,SeqFeatureI sb) { boolean overlap = false; ! if (sb instanceof FeatureSetI) { FeatureSetI fb = (FeatureSetI)sb; for (int i=0; i<fb.size() && !overlap; i++) { --- 18,22 ---- public boolean areOverlapping(SeqFeatureI sa,SeqFeatureI sb) { boolean overlap = false; ! if (sb.canHaveChildren()) { FeatureSetI fb = (FeatureSetI)sb; for (int i=0; i<fb.size() && !overlap; i++) { *************** *** 24,28 **** } } ! else if (sa instanceof FeatureSetI) { FeatureSetI fa = (FeatureSetI)sa; for (int i=0; i<fa.size() && !overlap; i++) { --- 24,28 ---- } } ! else if (sa.canHaveChildren()) { FeatureSetI fa = (FeatureSetI)sa; for (int i=0; i<fa.size() && !overlap; i++) { |