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:
546cce1
)
JAL-4366 compute coverage on each side of the pairwise alignment
author
James Procter
<j.procter@dundee.ac.uk>
Fri, 15 Dec 2023 13:56:07 +0000
(13:56 +0000)
committer
James Procter
<j.procter@dundee.ac.uk>
Fri, 15 Dec 2023 13:56:07 +0000
(13:56 +0000)
src/jalview/analysis/AlignSeq.java
patch
|
blob
|
history
diff --git
a/src/jalview/analysis/AlignSeq.java
b/src/jalview/analysis/AlignSeq.java
index
36d2482
..
75ccdfc
100755
(executable)
--- a/
src/jalview/analysis/AlignSeq.java
+++ b/
src/jalview/analysis/AlignSeq.java
@@
-93,6
+93,11
@@
public class AlignSeq
int[] aseq1;
int[] aseq2;
int[] aseq1;
int[] aseq2;
+
+ /*
+ * matches in alignment
+ */
+ int match=-1;
public String astr1 = "";
public String astr1 = "";
@@
-281,6
+286,30
@@
public class AlignSeq
s2.getDatasetSequence() == null ? s2 : s2.getDatasetSequence());
return alSeq2;
}
s2.getDatasetSequence() == null ? s2 : s2.getDatasetSequence());
return alSeq2;
}
+ /**
+ * fraction of seq2 matched in the alignment
+ * @return NaN or [0..1]
+ */
+ public double getS2Coverage()
+ {
+ if (match>=0)
+ {
+ return ((double)match)/((double)s2.getEnd()-s2.getStart()+1);
+ }
+ return Double.NaN;
+ }
+ /**
+ * fraction of seq1 matched in the alignment
+ * @return NaN or [0..1]
+ */
+ public double getS1Coverage()
+ {
+ if (match>=0)
+ {
+ return ((double)match)/((double)s1.getEnd()-s1.getStart()+1);
+ }
+ return Double.NaN;
+ }
/**
* Construct score matrix for sequences with standard DNA or PEPTIDE matrix
/**
* Construct score matrix for sequences with standard DNA or PEPTIDE matrix
@@
-390,7
+419,7
@@
public class AlignSeq
aseq1 = new int[seq1.length + seq2.length];
aseq2 = new int[seq1.length + seq2.length];
aseq1 = new int[seq1.length + seq2.length];
aseq2 = new int[seq1.length + seq2.length];
-
+ match=0;
StringBuilder sb1 = new StringBuilder(aseq1.length);
StringBuilder sb2 = new StringBuilder(aseq2.length);
StringBuilder sb1 = new StringBuilder(aseq1.length);
StringBuilder sb2 = new StringBuilder(aseq2.length);
@@
-402,11
+431,11
@@
public class AlignSeq
sb1.append(s1str.charAt(i));
aseq2[count] = seq2[j];
sb2.append(s2str.charAt(j));
sb1.append(s1str.charAt(i));
aseq2[count] = seq2[j];
sb2.append(s2str.charAt(j));
-
trace = findTrace(i, j);
if (trace == 0)
{
trace = findTrace(i, j);
if (trace == 0)
{
+ match++;
i--;
j--;
}
i--;
j--;
}
@@
-439,8
+468,10
@@
public class AlignSeq
{
aseq2[count] = seq2[j];
sb2.append(s2str.charAt(j));
{
aseq2[count] = seq2[j];
sb2.append(s2str.charAt(j));
+ if (aseq1[count]!=GAP_INDEX) {
+ match++;
+ }
}
}
-
/*
* we built the character strings backwards, so now
* reverse them to convert to sequence strings
/*
* we built the character strings backwards, so now
* reverse them to convert to sequence strings