*/
package jalview.analysis;
-import java.awt.Color;
-import java.awt.Graphics;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.StringTokenizer;
-
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Mapping;
import jalview.util.MapList;
import jalview.util.MessageManager;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.StringTokenizer;
+
/**
*
*
private static final String NEWLINE = System.lineSeparator();
- static String[] dna =
- { "A", "C", "G", "T", "-" };
+ static String[] dna = { "A", "C", "G", "T", "-" };
// "C", "T", "A", "G", "-"};
- static String[] pep =
- { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
- "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-" };
+ static String[] pep = { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I",
+ "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-" };
int[][] score;
else
{
output.append("Wrong type = dna or pep only");
- throw new Error(MessageManager.formatMessage("error.unknown_type_dna_or_pep", new String[]{type2}));
+ throw new Error(MessageManager.formatMessage(
+ "error.unknown_type_dna_or_pep", new String[] { type2 }));
}
}
}
}
int len = 72 - maxid - 1;
- int nochunks = ((aseq1.length - count) / len) + 1;
+ int nochunks = ((aseq1.length - count) / len)
+ + ((aseq1.length - count) % len > 0 ? 1 : 0);
pid = 0;
output.append("Score = ").append(score[maxi][maxj]).append(NEWLINE);
}
pid = pid / (aseq1.length - count) * 100;
- output = output.append(new Format("Percentage ID = %2.2f\n\n")
+ output = output.append(new Format("Percentage ID = %2.2f\n")
.form(pid));
-
try
{
os.print(output.toString());
public static void displayMatrix(Graphics g, int[][] mat, int n, int m,
int psize)
{
+ // TODO method dosen't seem to be referenced anywhere delete??
int max = -1000;
int min = 1000;
*/
public static List<List<? extends Object>> replaceMatchingSeqsWith(
List<SequenceI> seqs, List<AlignmentAnnotation> annotations,
- List<SequenceI> ochains,
- AlignmentI al, String dnaOrProtein, boolean removeOldAnnots)
+ List<SequenceI> ochains, AlignmentI al, String dnaOrProtein,
+ boolean removeOldAnnots)
{
List<SequenceI> orig = new ArrayList<SequenceI>(), repl = new ArrayList<SequenceI>();
List<AlignSeq> aligs = new ArrayList<AlignSeq>();
{
ArrayList<SequenceI> matches = new ArrayList<SequenceI>();
ArrayList<AlignSeq> aligns = new ArrayList<AlignSeq>();
-
+
for (SequenceI sq : ochains)
{
SequenceI bestm = null;
int bestscore = 0;
for (SequenceI msq : al.getSequences())
{
- AlignSeq aseq = doGlobalNWAlignment(msq, sq,
- dnaOrProtein);
+ AlignSeq aseq = doGlobalNWAlignment(msq, sq, dnaOrProtein);
if (bestm == null || aseq.getMaxScore() > bestscore)
{
bestscore = aseq.getMaxScore();
sq.setName(sp.getName());
sq.setDescription(sp.getDescription());
Mapping sp2sq;
- sq.transferAnnotation(sp, sp2sq = aligns.get(q).getMappingFromS1(false));
+ sq.transferAnnotation(sp,
+ sp2sq = aligns.get(q).getMappingFromS1(false));
aligs.add(aligns.get(q));
int inspos = -1;
for (int ap = 0; ap < annotations.size();)
{
inspos = ap;
}
- if (removeOldAnnots) {
+ if (removeOldAnnots)
+ {
annotations.remove(ap);
- } else {
+ }
+ else
+ {
AlignmentAnnotation alan = annotations.remove(ap);
alan.liftOver(sq, sp2sq);
alan.setSequenceRef(sq);
SequenceI[] originalSequences, String[] omitHidden, int start,
int end, boolean ungapped)
{
+ return (float[]) computeRedundancyMatrixWithRep(originalSequences,
+ omitHidden, start, end, ungapped)[0];
+ }
+
+ public static Object[] computeRedundancyMatrixWithRep(
+ SequenceI[] originalSequences, String[] omitHidden, int start,
+ int end, boolean ungapped)
+ {
+
int height = originalSequences.length;
float[] redundancy = new float[height];
+ SequenceI[] rep = new SequenceI[height];
int[] lngth = new int[height];
for (int i = 0; i < height; i++)
{
// use real sequence length rather than string length
if (lngth[j] < lngth[i])
{
- redundancy[j] = Math.max(pid, redundancy[j]);
+ if (pid > redundancy[j])
+ {
+ rep[j] = originalSequences[i];
+ redundancy[j] = pid;
+ }
}
else
{
- redundancy[i] = Math.max(pid, redundancy[i]);
+ if (pid > redundancy[i])
+ {
+ rep[i] = originalSequences[j];
+ redundancy[i] = pid;
+ }
}
}
}
- return redundancy;
+ return new Object[] { redundancy, rep };
}
}