git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0bf5983
)
JAL-3794 X and N are counted as DNA characters, but we also check how many Ns - if...
author
Jim Procter
<jprocter@issues.jalview.org>
Fri, 8 Jan 2021 16:06:59 +0000
(16:06 +0000)
committer
Ben Soares
<b.soares@dundee.ac.uk>
Thu, 16 Sep 2021 09:50:29 +0000
(10:50 +0100)
src/jalview/util/Comparison.java
patch
|
blob
|
history
diff --git
a/src/jalview/util/Comparison.java
b/src/jalview/util/Comparison.java
index
286bfb2
..
0d945ac
100644
(file)
--- a/
src/jalview/util/Comparison.java
+++ b/
src/jalview/util/Comparison.java
@@
-261,7
+261,7
@@
public class Comparison
/**
* Overloaded method signature to test whether a single sequence is nucleotide
/**
* Overloaded method signature to test whether a single sequence is nucleotide
- * (that is, more than 85% CGTA)
+ * (that is, more than 85% CGTAUNX)
*
* @param seq
* @return
*
* @param seq
* @return
@@
-274,27
+274,32
@@
public class Comparison
}
long ntCount = 0;
long aaCount = 0;
}
long ntCount = 0;
long aaCount = 0;
+ long nCount = 0;
int len = seq.getLength();
for (int i = 0; i < len; i++)
{
char c = seq.getCharAt(i);
int len = seq.getLength();
for (int i = 0; i < len; i++)
{
char c = seq.getCharAt(i);
- if (isNucleotide(c))
+ if (isNucleotide(c) || isX(c))
{
ntCount++;
}
else if (!isGap(c))
{
aaCount++;
{
ntCount++;
}
else if (!isGap(c))
{
aaCount++;
+ if (isN(c))
+ {
+ nCount++;
+ }
}
}
/*
* Check for nucleotide count > 85% of total count (in a form that evades
* int / float conversion or divide by zero).
*/
}
}
/*
* Check for nucleotide count > 85% of total count (in a form that evades
* int / float conversion or divide by zero).
*/
- if (ntCount * 100 > EIGHTY_FIVE * (ntCount + aaCount))
+ if ((ntCount+nCount) * 100 > EIGHTY_FIVE * (ntCount + aaCount))
{
{
- return true;
+ return ntCount>0; // all N is considered protein. Could use a threshold here too
}
else
{
}
else
{
@@
-317,17
+322,18
@@
public class Comparison
return false;
}
// true if we have seen a nucleotide sequence
return false;
}
// true if we have seen a nucleotide sequence
- boolean na=false;
+ boolean na = false;
for (SequenceI seq : seqs)
{
if (seq == null)
{
continue;
}
for (SequenceI seq : seqs)
{
if (seq == null)
{
continue;
}
- na=true;
+ na = true;
// TODO could possibly make an informed guess just from the first sequence
// to save a lengthy calculation
// TODO could possibly make an informed guess just from the first sequence
// to save a lengthy calculation
- if (seq.isProtein()) {
+ if (seq.isProtein())
+ {
// if even one looks like protein, the alignment is protein
return false;
}
// if even one looks like protein, the alignment is protein
return false;
}
@@
-347,7
+353,6
@@
public class Comparison
{
c -= TO_UPPER_CASE;
}
{
c -= TO_UPPER_CASE;
}
-
switch (c)
{
case 'A':
switch (c)
{
case 'A':
@@
-360,6
+365,28
@@
public class Comparison
return false;
}
return false;
}
+ public static boolean isN(char c)
+ {
+ switch (c)
+ {
+ case 'N':
+ case 'n':
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isX(char c)
+ {
+ switch (c)
+ {
+ case 'X':
+ case 'x':
+ return true;
+ }
+ return false;
+ }
+
/**
* Answers true if every character in the string is one of aAcCgGtTuU, or
* (optionally) a gap character (dot, dash, space), else false
/**
* Answers true if every character in the string is one of aAcCgGtTuU, or
* (optionally) a gap character (dot, dash, space), else false