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-3206 avoid divide by zero when threshold is graphMin / graphMax
[jalview.git]
/
src
/
jalview
/
datamodel
/
Sequence.java
diff --git
a/src/jalview/datamodel/Sequence.java
b/src/jalview/datamodel/Sequence.java
index
59c3fb1
..
80310c0
100755
(executable)
--- a/
src/jalview/datamodel/Sequence.java
+++ b/
src/jalview/datamodel/Sequence.java
@@
-43,10
+43,7
@@
import fr.orsay.lri.varna.models.rna.RNA;
/**
*
/**
*
- * Implements the SequenceI interface for a char[] based sequence object.
- *
- * @author $author$
- * @version $Revision$
+ * Implements the SequenceI interface for a char[] based sequence object
*/
public class Sequence extends ASequence implements SequenceI
{
*/
public class Sequence extends ASequence implements SequenceI
{
@@
-445,7
+442,7
@@
public class Sequence extends ASequence implements SequenceI
@Override
public Vector<PDBEntry> getAllPDBEntries()
{
@Override
public Vector<PDBEntry> getAllPDBEntries()
{
- return pdbIds == null ? new Vector<PDBEntry>() : pdbIds;
+ return pdbIds == null ? new Vector<>() : pdbIds;
}
/**
}
/**
@@
-797,6
+794,7
@@
public class Sequence extends ASequence implements SequenceI
* preserve end residue column provided cursor was valid
*/
int endColumn = isValidCursor(cursor) ? cursor.lastColumnPosition : 0;
* preserve end residue column provided cursor was valid
*/
int endColumn = isValidCursor(cursor) ? cursor.lastColumnPosition : 0;
+
if (residuePos == this.end)
{
endColumn = column;
if (residuePos == this.end)
{
endColumn = column;
@@
-815,7
+813,7
@@
public class Sequence extends ASequence implements SequenceI
* @param curs
* @return
*/
* @param curs
* @return
*/
- protected int findIndex(int pos, SequenceCursor curs)
+ protected int findIndex(final int pos, SequenceCursor curs)
{
if (!isValidCursor(curs))
{
{
if (!isValidCursor(curs))
{
@@
-833,16
+831,20
@@
public class Sequence extends ASequence implements SequenceI
/*
* move left or right to find pos from hint.position
*/
/*
* move left or right to find pos from hint.position
*/
- int col = curs.columnPosition - 1; // convert from base 1 to 0-based array
- // index
+ int col = curs.columnPosition - 1; // convert from base 1 to base 0
int newPos = curs.residuePosition;
int delta = newPos > pos ? -1 : 1;
while (newPos != pos)
{
col += delta; // shift one column left or right
int newPos = curs.residuePosition;
int delta = newPos > pos ? -1 : 1;
while (newPos != pos)
{
col += delta; // shift one column left or right
- if (col < 0 || col == sequence.length)
+ if (col < 0)
+ {
+ break;
+ }
+ if (col == sequence.length)
{
{
+ col--; // return last column if we failed to reach pos
break;
}
if (!Comparison.isGap(sequence[col]))
break;
}
if (!Comparison.isGap(sequence[col]))
@@
-852,7
+854,14
@@
public class Sequence extends ASequence implements SequenceI
}
col++; // convert back to base 1
}
col++; // convert back to base 1
- updateCursor(pos, col, curs.firstColumnPosition);
+
+ /*
+ * only update cursor if we found the target position
+ */
+ if (newPos == pos)
+ {
+ updateCursor(pos, col, curs.firstColumnPosition);
+ }
return col;
}
return col;
}
@@
-1057,7
+1066,7
@@
public class Sequence extends ASequence implements SequenceI
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- public Range findPositions(int fromColumn, int toColumn)
+ public ContiguousI findPositions(int fromColumn, int toColumn)
{
if (toColumn < fromColumn || fromColumn < 1)
{
{
if (toColumn < fromColumn || fromColumn < 1)
{
@@
-1251,12
+1260,13
@@
public class Sequence extends ASequence implements SequenceI
boolean createNewDs = false;
// TODO: take a (second look) at the dataset creation validation method for
// the very large sequence case
boolean createNewDs = false;
// TODO: take a (second look) at the dataset creation validation method for
// the very large sequence case
+
int startIndex = findIndex(start) - 1;
int endIndex = findIndex(end) - 1;
int startDeleteColumn = -1; // for dataset sequence deletions
int deleteCount = 0;
int startIndex = findIndex(start) - 1;
int endIndex = findIndex(end) - 1;
int startDeleteColumn = -1; // for dataset sequence deletions
int deleteCount = 0;
- for (int s = i; s < j; s++)
+ for (int s = i; s < j && s < sequence.length; s++)
{
if (Comparison.isGap(sequence[s]))
{
{
if (Comparison.isGap(sequence[s]))
{
@@
-1901,6
+1911,15
@@
public class Sequence extends ASequence implements SequenceI
List<SequenceFeature> result = getFeatures().findFeatures(startPos,
endPos, types);
List<SequenceFeature> result = getFeatures().findFeatures(startPos,
endPos, types);
+ if (datasetSequence != null)
+ {
+ result = datasetSequence.getFeatures().findFeatures(startPos, endPos,
+ types);
+ }
+ else
+ {
+ result = sequenceFeatureStore.findFeatures(startPos, endPos, types);
+ }
/*
* if end column is gapped, endPos may be to the right,
/*
* if end column is gapped, endPos may be to the right,