git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-1894 update year/version in copyright
[jalview.git]
/
src
/
jalview
/
datamodel
/
Mapping.java
diff --git
a/src/jalview/datamodel/Mapping.java
b/src/jalview/datamodel/Mapping.java
index
2e76e41
..
e585457
100644
(file)
--- a/
src/jalview/datamodel/Mapping.java
+++ b/
src/jalview/datamodel/Mapping.java
@@
-1,5
+1,5
@@
/*
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1)
* Copyright (C) 2015 The Jalview Authors
*
* This file is part of Jalview.
* Copyright (C) 2015 The Jalview Authors
*
* This file is part of Jalview.
@@
-48,6
+48,11
@@
public class Mapping
private final char[] alignedSeq;
/*
private final char[] alignedSeq;
/*
+ * the sequence start residue
+ */
+ private int start;
+
+ /*
* Next position (base 0) in the aligned sequence
*/
private int alignedColumn = 0;
* Next position (base 0) in the aligned sequence
*/
private int alignedColumn = 0;
@@
-90,13
+95,14
@@
public class Mapping
/**
* Constructor
*
/**
* Constructor
*
- * @param cs
- * the aligned sequence characters
+ * @param seq
+ * the aligned sequence
* @param gapChar
*/
* @param gapChar
*/
- public AlignedCodonIterator(char[] cs, char gapChar)
+ public AlignedCodonIterator(SequenceI seq, char gapChar)
{
{
- this.alignedSeq = cs;
+ this.alignedSeq = seq.getSequence();
+ this.start = seq.getStart();
this.gap = gapChar;
fromRanges = map.getFromRanges().iterator();
toRanges = map.getToRanges().iterator();
this.gap = gapChar;
fromRanges = map.getFromRanges().iterator();
toRanges = map.getToRanges().iterator();
@@
-165,7
+171,8
@@
public class Mapping
// i.e. code like getNextCodon()
if (toPosition <= currentToRange[1])
{
// i.e. code like getNextCodon()
if (toPosition <= currentToRange[1])
{
- char pep = Mapping.this.to.getSequence()[toPosition - 1];
+ SequenceI seq = Mapping.this.to;
+ char pep = seq.getSequence()[toPosition - seq.getStart()];
toPosition++;
return String.valueOf(pep);
}
toPosition++;
return String.valueOf(pep);
}
@@
-242,8
+249,11
@@
public class Mapping
*/
private int getAlignedColumn(int sequencePos)
{
*/
private int getAlignedColumn(int sequencePos)
{
- while (alignedBases < sequencePos
- && alignedColumn < alignedSeq.length)
+ /*
+ * allow for offset e.g. treat pos 8 as 2 if sequence starts at 7
+ */
+ int truePos = sequencePos - (start - 1);
+ while (alignedBases < truePos && alignedColumn < alignedSeq.length)
{
if (alignedSeq[alignedColumn++] != gap)
{
{
if (alignedSeq[alignedColumn++] != gap)
{
@@
-692,7
+702,7
@@
public class Mapping
public Iterator<AlignedCodon> getCodonIterator(SequenceI seq, char gapChar)
{
public Iterator<AlignedCodon> getCodonIterator(SequenceI seq, char gapChar)
{
- return new AlignedCodonIterator(seq.getSequence(), gapChar);
+ return new AlignedCodonIterator(seq, gapChar);
}
}
}
}