X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FDna.java;h=49c37df7f2d810881c0bc55e7a3a6b21c2f4f8ea;hb=a45774ee31d9f35d4eff46d54d7deab719afb092;hp=ce13665cdf2dfb60812c1f81695d5aa7490ce82d;hpb=2de8acfae59aced665e4c37ad0f7dcc2ed68818e;p=jalview.git diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index ce13665..49c37df 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) - * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, 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 file is part of Jalview. * - * 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. + * Jalview 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 3 of the License, or (at your option) any later version. * - * 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 + * Jalview 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 Jalview. If not, see . */ package jalview.analysis; @@ -85,7 +84,7 @@ public class Dna * @param annotations * @param aWidth * @param dataset - * destination dataset for translated sequences and mappings + * destination dataset for translated sequences and mappings * @return */ public static AlignmentI CdnaTranslate(SequenceI[] selection, @@ -100,9 +99,9 @@ public class Dna * * @param selection * @param seqstring - * @param product - - * array of DbRefEntry objects from which exon map in seqstring - * is derived + * @param product + * - array of DbRefEntry objects from which exon map in seqstring is + * derived * @param viscontigs * @param gapCharacter * @param annotations @@ -128,7 +127,7 @@ public class Dna SequenceI newseq = translateCodingRegion(selection[s], seqstring[s], viscontigs, codons, gapCharacter, (product != null) ? product[s] : null); // possibly anonymous - // product + // product if (newseq != null) { pepseqs.addElement(newseq); @@ -215,7 +214,7 @@ public class Dna * @param viscontigs * @param gapCharacter * @param dataset - * destination dataset for translated sequences + * destination dataset for translated sequences * @param annotations * @param aWidth * @return @@ -364,28 +363,60 @@ public class Dna { // Have a look at all the codon positions for annotation and put the first // one found into the translated annotation pos. + int contrib = 0; + Annotation annot = null; for (int p = 0; p < 3; p++) { if (annotations[is[p]] != null) { - return new Annotation(annotations[is[p]]); + if (annot == null) + { + annot = new Annotation(annotations[is[p]]); + contrib = 1; + } + else + { + // merge with last + Annotation cpy = new Annotation(annotations[is[p]]); + if (annot.colour == null) + { + annot.colour = cpy.colour; + } + if (annot.description == null || annot.description.length() == 0) + { + annot.description = cpy.description; + } + if (annot.displayCharacter == null) + { + annot.displayCharacter = cpy.displayCharacter; + } + if (annot.secondaryStructure == 0) + { + annot.secondaryStructure = cpy.secondaryStructure; + } + annot.value += cpy.value; + contrib++; + } } } - return null; + if (contrib > 1) + { + annot.value /= (float) contrib; + } + return annot; } /** * Translate a na sequence * * @param selection - * sequence displayed under viscontigs visible columns + * sequence displayed under viscontigs visible columns * @param seqstring - * ORF read in some global alignment reference frame + * ORF read in some global alignment reference frame * @param viscontigs - * mapping from global reference frame to visible seqstring ORF - * read + * mapping from global reference frame to visible seqstring ORF read * @param codons - * Definition of global ORF alignment reference frame + * Definition of global ORF alignment reference frame * @param gapCharacter * @param newSeq * @return sequence ready to be added to alignment. @@ -517,8 +548,9 @@ public class Dna } if (aspos >= codons.aaWidth) { - // update maximum alignment width - // (we can do this without calling checkCodonFrameWidth because it was already done above) + // update maximum alignment width + // (we can do this without calling checkCodonFrameWidth because it was + // already done above) codons.setAaWidth(aspos); } // ready for next translated reading frame alignment position (if any) @@ -527,8 +559,8 @@ public class Dna } if (resSize > 0) { - SequenceI newseq = new Sequence(selection.getName(), protein - .toString()); + SequenceI newseq = new Sequence(selection.getName(), + protein.toString()); if (rf != 0) { jalview.bin.Cache.log @@ -587,14 +619,13 @@ public class Dna * new ranges to exclude untranslated regions. if (skip.size()>0) { * Vector narange = new Vector(); for (vc=0; vc=skipint[0] && iv[0]<=skipint[1]) { if (iv[0]==skipint[0]) { // - * delete beginning of range } else { // truncate range and create new - * one if necessary iv = (int[]) narange.elementAt(vc+1); if (iv[0]<=skipint[1]) { // - * truncate range iv[0] = skipint[1]; } else { - * } } } else if (iv[0]=skipint[0] && + * iv[0]<=skipint[1]) { if (iv[0]==skipint[0]) { // delete beginning of + * range } else { // truncate range and create new one if necessary iv = + * (int[]) narange.elementAt(vc+1); if (iv[0]<=skipint[1]) { // truncate + * range iv[0] = skipint[1]; } else { } } } else if (iv[0]