X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FDna.java;h=bb72baf00552103542e64738fec203405524e2d0;hb=84be4eb6c9cf1ba25cebb64ae95979b9607ccaa3;hp=8bf8962f71d8cba98fe14280c3014580d87a2b30;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git
diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java
index 8bf8962..bb72baf 100644
--- a/src/jalview/analysis/Dna.java
+++ b/src/jalview/analysis/Dna.java
@@ -1,20 +1,19 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6.1)
+ * Copyright (C) 2010 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.
@@ -515,17 +546,21 @@ public class Dna
codons.codons[aspos] = new int[]
{ cdp[0], cdp[1], cdp[2] };
}
- aspos++;
if (aspos >= codons.aaWidth)
{
- codons.aaWidth = aspos + 1;
+ // 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)
+ aspos++;
}
}
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
@@ -584,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]