X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FCrossRef.java;h=8bc844bc3bc3e46d906fd80f26f0620c96d540ee;hb=5c212e384ee48b37d899cc88fc3d12c5028cc3b4;hp=f355d1f09c6d139e8c82344e91e46c97de635cd7;hpb=6b406c397d41a0f2d84b75f13e7ab478932bf57d;p=jalview.git diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index f355d1f..8bc844b 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -1,3 +1,21 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.analysis; import java.util.Enumeration; @@ -158,7 +176,9 @@ public class CrossRef { if (cdna[c].getSource().equals(DBRefSource.EMBLCDS)) { - // retrieve CDS dataset sequences + System.err + .println("TODO: unimplemented sequence retrieval for coding region sequence."); + // TODO: retrieve CDS dataset sequences // need global dataset sequence retriever/resolver to reuse refs // and construct Mapping entry. // insert gaps in CDS according to peptide gaps. @@ -305,7 +325,10 @@ public class CrossRef xrfs = t; try { - retrieved = sftch.getSequences(xrfs); // problem here is we don't know which of xrfs resulted in which retrieved element + retrieved = sftch.getSequences(xrfs); // problem here is we don't + // know which of xrfs + // resulted in which + // retrieved element } catch (Exception e) { System.err @@ -318,32 +341,39 @@ public class CrossRef for (int rs = 0; rs < retrieved.length; rs++) { // TODO: examine each sequence for 'redundancy' - jalview.datamodel.DBRefEntry[] dbr = retrieved[rs].getDBRef(); + jalview.datamodel.DBRefEntry[] dbr = retrieved[rs] + .getDBRef(); if (dbr != null && dbr.length > 0) { for (int di = 0; di < dbr.length; di++) { - // find any entry where we should put in the sequence being cross-referenced into the map + // find any entry where we should put in the sequence being + // cross-referenced into the map jalview.datamodel.Mapping map = dbr[di].getMap(); if (map != null) { if (map.getTo() != null && map.getMap() != null) { - // should search the local dataset to find any existing candidates for To ! + // should search the local dataset to find any existing + // candidates for To ! try { - // compare ms with dss and replace with dss in mapping if map is congruent + // compare ms with dss and replace with dss in mapping + // if map is congruent SequenceI ms = map.getTo(); int sf = map.getMap().getToLowest(); int st = map.getMap().getToHighest(); SequenceI mappedrg = ms.getSubSequence(sf, st); SequenceI loc = dss.getSubSequence(sf, st); - if (mappedrg.getLength()>0 && mappedrg.getSequenceAsString().equals( - loc.getSequenceAsString())) + if (mappedrg.getLength() > 0 + && mappedrg.getSequenceAsString().equals( + loc.getSequenceAsString())) { System.err .println("Mapping updated for retrieved crossreference"); - // method to update all refs of existing To on retrieved sequence with dss and merge any props on To onto dss. + // method to update all refs of existing To on + // retrieved sequence with dss and merge any props + // on To onto dss. map.setTo(dss); } } catch (Exception e) @@ -444,6 +474,7 @@ public class CrossRef boolean direct, boolean dna) { boolean found = false; + SequenceI[] typer = new SequenceI[1]; if (dataset == null) return false; if (dataset.getSequences() == null) @@ -464,6 +495,17 @@ public class CrossRef } if (nxt != sequenceI && nxt != sequenceI.getDatasetSequence()) { + // check if this is the correct sequence type + { + typer[0] = nxt; + boolean isDna = jalview.util.Comparison.isNucleotide(typer); + if ((direct && isDna == dna) || (!direct && isDna != dna)) + { + // skip this sequence because it is same molecule type + continue; + } + } + // look for direct or indirect references in common DBRefEntry[] poss = null, cands = null; if (direct) @@ -537,16 +579,17 @@ public class CrossRef * System.out.println("Found " + ((prod == null) ? "no" : "" + * prod.length) + " products"); if (prod!=null) { for (int p=0; p