X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fgff%2FExonerateHelper.java;h=da0c245e5f604171d177fe5ad5771b662d1654f9;hb=bed0c230be450b16213e30ee1dcaf3e76ddfc669;hp=e37386177be417510aaae8d2982140258ae3c720;hpb=8f920d337154e092f5f9056ffde3cdf2735eca43;p=jalview.git
diff --git a/src/jalview/io/gff/ExonerateHelper.java b/src/jalview/io/gff/ExonerateHelper.java
index e373861..da0c245 100644
--- a/src/jalview/io/gff/ExonerateHelper.java
+++ b/src/jalview/io/gff/ExonerateHelper.java
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * 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.
+ *
+ * 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 .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.io.gff;
import jalview.datamodel.AlignedCodonFrame;
@@ -41,7 +61,7 @@ public class ExonerateHelper extends Gff2Helper
*
* @param seq
* the sequence with which this feature is associated
- * @param sf
+ * @param gffColumns
* the sequence feature with ATTRIBUTES property containing any
* additional attributes
* @param align
@@ -64,8 +84,8 @@ public class ExonerateHelper extends Gff2Helper
try
{
- processGffSimilarity(set, seq, gffColumns,
- align, newseqs, relaxedIdMatching);
+ processGffSimilarity(set, seq, gffColumns, align, newseqs,
+ relaxedIdMatching);
} catch (IOException ivfe)
{
System.err.println(ivfe);
@@ -98,8 +118,7 @@ public class ExonerateHelper extends Gff2Helper
* if true allow fuzzy search for a matching target sequence
* @throws IOException
*/
- protected void processGffSimilarity(
- Map> set,
+ protected void processGffSimilarity(Map> set,
SequenceI seq, String[] gff, AlignmentI align,
List newseqs, boolean relaxedIdMatching)
throws IOException
@@ -146,7 +165,8 @@ public class ExonerateHelper extends Gff2Helper
SequenceI mapFromSequence = seq;
SequenceI mapToSequence = mappedSequence;
if ((type == MappingType.NucleotideToPeptide && featureIsOnTarget)
- || (type == MappingType.PeptideToNucleotide && !featureIsOnTarget))
+ || (type == MappingType.PeptideToNucleotide
+ && !featureIsOnTarget))
{
mapFromSequence = mappedSequence;
mapToSequence = seq;
@@ -167,7 +187,7 @@ public class ExonerateHelper extends Gff2Helper
mapToSequence);
/*
- * exonerate GFF has the strand of the target in column 7 rather
+ * exonerate GFF has the strand of the target in column 7
* (differs from GFF3 which has it in the Target descriptor)
*/
String strand = gff[STRAND_COL];
@@ -228,15 +248,17 @@ public class ExonerateHelper extends Gff2Helper
int alignFromStart;
int alignToStart;
int alignCount;
- try {
+ try
+ {
alignFromStart = Integer.parseInt(tokens[0]);
alignToStart = Integer.parseInt(tokens[1]);
alignCount = Integer.parseInt(tokens[2]);
- } catch (NumberFormatException nfe) {
+ } catch (NumberFormatException nfe)
+ {
System.err.println(nfe.toString());
return null;
}
-
+
int fromStart;
int fromEnd;
int toStart;
@@ -246,8 +268,8 @@ public class ExonerateHelper extends Gff2Helper
{
fromStart = alignToStart;
toStart = alignFromStart;
- toEnd = forwardStrand ? toStart + alignCount - 1 : toStart
- - (alignCount - 1);
+ toEnd = forwardStrand ? toStart + alignCount - 1
+ : toStart - (alignCount - 1);
int toLength = Math.abs(toEnd - toStart) + 1;
int fromLength = toLength * type.getFromRatio() / type.getToRatio();
fromEnd = fromStart + fromLength - 1;
@@ -290,10 +312,8 @@ public class ExonerateHelper extends Gff2Helper
{
result = MappingType.PeptideToNucleotide;
}
- else if (model.contains(CODING2CODING)
- || model.contains(CODING2GENOME)
- || model.contains(CDNA2GENOME)
- || model.contains(GENOME2GENOME))
+ else if (model.contains(CODING2CODING) || model.contains(CODING2GENOME)
+ || model.contains(CDNA2GENOME) || model.contains(GENOME2GENOME))
{
result = MappingType.NucleotideToNucleotide;
}
@@ -304,7 +324,7 @@ public class ExonerateHelper extends Gff2Helper
* Tests whether the GFF data looks like it was generated by exonerate, and is
* a format we are willing to handle
*
- * @param sf
+ * @param columns
* @return
*/
public static boolean recognises(String[] columns)
@@ -323,10 +343,8 @@ public class ExonerateHelper extends Gff2Helper
{
String mdl = model.toLowerCase();
if (mdl.contains(PROTEIN2DNA) || mdl.contains(PROTEIN2GENOME)
- || mdl.contains(CODING2CODING)
- || mdl.contains(CODING2GENOME)
- || mdl.contains(CDNA2GENOME)
- || mdl.contains(GENOME2GENOME))
+ || mdl.contains(CODING2CODING) || mdl.contains(CODING2GENOME)
+ || mdl.contains(CDNA2GENOME) || mdl.contains(GENOME2GENOME))
{
return true;
}
@@ -335,12 +353,16 @@ public class ExonerateHelper extends Gff2Helper
return false;
}
+ /**
+ * An override to set feature group to "exonerate" instead of the default GFF
+ * source value (column 2)
+ */
@Override
protected SequenceFeature buildSequenceFeature(String[] gff,
Map> set)
{
- SequenceFeature sf = super.buildSequenceFeature(gff, set);
- sf.setFeatureGroup("exonerate");
+ SequenceFeature sf = super.buildSequenceFeature(gff, TYPE_COL,
+ "exonerate", set);
return sf;
}