import jalview.analysis.scoremodels.PIDModel;
import jalview.analysis.scoremodels.ScoreMatrix;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.analysis.scoremodels.PIDModel;
import jalview.analysis.scoremodels.ScoreMatrix;
import jalview.analysis.scoremodels.ScoreModels;
StringBuffer output = new StringBuffer();
String type; // AlignSeq.PEP or AlignSeq.DNA
private ScoreMatrix scoreMatrix;
StringBuffer output = new StringBuffer();
String type; // AlignSeq.PEP or AlignSeq.DNA
private ScoreMatrix scoreMatrix;
- * @param s1 first sequence for alignment
- * @param s2 second sequence for alignment
- * @param type molecule type, either AlignSeq.PEP or AlignSeq.DNA
+ * @param s1
+ * first sequence for alignment
+ * @param s2
+ * second sequence for alignment
+ * @param type
+ * molecule type, either AlignSeq.PEP or AlignSeq.DNA
public AlignSeq(SequenceI s1, String string1, SequenceI s2,
String string2, String type)
{
public AlignSeq(SequenceI s1, String string1, SequenceI s2,
String string2, String type)
{
- seqInit(s1, string1.toUpperCase(), s2, string2.toUpperCase(), type);
+ seqInit(s1, string1.toUpperCase(Locale.ROOT), s2,
+ string2.toUpperCase(Locale.ROOT), type);
SequenceI alSeq1 = new Sequence(s1.getName(), getAStr1());
alSeq1.setStart(s1.getStart() + getSeq1Start() - 1);
alSeq1.setEnd(s1.getStart() + getSeq1End() - 1);
SequenceI alSeq1 = new Sequence(s1.getName(), getAStr1());
alSeq1.setStart(s1.getStart() + getSeq1Start() - 1);
alSeq1.setEnd(s1.getStart() + getSeq1End() - 1);
SequenceI alSeq2 = new Sequence(s2.getName(), getAStr2());
alSeq2.setStart(s2.getStart() + getSeq2Start() - 1);
alSeq2.setEnd(s2.getStart() + getSeq2End() - 1);
SequenceI alSeq2 = new Sequence(s2.getName(), getAStr2());
alSeq2.setStart(s2.getStart() + getSeq2Start() - 1);
alSeq2.setEnd(s2.getStart() + getSeq2End() - 1);
- output.append("ALL GAPS: "
- + (s1str.length() == 0 ? s1.getName() : " ")
- + (s2str.length() == 0 ? s2.getName() : ""));
+ output.append(
+ "ALL GAPS: " + (s1str.length() == 0 ? s1.getName() : " ")
+ + (s2str.length() == 0 ? s2.getName() : ""));
if (!PEP.equals(moleculeType) && !DNA.equals(moleculeType))
{
output.append("Wrong type = dna or pep only");
if (!PEP.equals(moleculeType) && !DNA.equals(moleculeType))
{
output.append("Wrong type = dna or pep only");
- throw new Error(MessageManager.formatMessage(
- "error.unknown_type_dna_or_pep",
- new String[] { moleculeType }));
+ throw new Error(MessageManager
+ .formatMessage("error.unknown_type_dna_or_pep", new String[]
+ { moleculeType }));
{
// TODO: Use original sequence characters rather than re-translated
// characters in output
// Find the biggest id length for formatting purposes
{
// TODO: Use original sequence characters rather than re-translated
// characters in output
// Find the biggest id length for formatting purposes
- String s1id = s1.getName(), s2id = s2.getName();
- int maxid = s1.getName().length();
- if (s2.getName().length() > maxid)
- {
- maxid = s2.getName().length();
- }
- if (maxid > 30)
+ String s1id = getAlignedSeq1().getDisplayId(true);
+ String s2id = getAlignedSeq2().getDisplayId(true);
+ int nameLength = Math.max(s1id.length(), s2id.length());
+ if (nameLength > MAX_NAME_LENGTH)
- s1id = s1.getName().substring(0, 30);
+ int slashPos = s1id.lastIndexOf('/');
+ s1id = s1id.substring(0, slashPos - truncateBy)
+ + s1id.substring(slashPos);
- s2id = s2.getName().substring(0, 30);
+ int slashPos = s2id.lastIndexOf('/');
+ s2id = s2id.substring(0, slashPos - truncateBy)
+ + s2id.substring(slashPos);
output.append("Score = ").append(score[maxi][maxj]).append(NEWLINE);
output.append("Length of alignment = ")
.append(String.valueOf(aseq1.length - count)).append(NEWLINE);
output.append("Sequence ");
output.append("Score = ").append(score[maxi][maxj]).append(NEWLINE);
output.append("Length of alignment = ")
.append(String.valueOf(aseq1.length - count)).append(NEWLINE);
output.append("Sequence ");
- output.append(new Format("%" + maxid + "s").form(s1.getName()));
- output.append(" : ").append(String.valueOf(s1.getStart()))
- .append(" - ").append(String.valueOf(s1.getEnd()));
+ Format nameFormat = new Format("%" + nameLength + "s");
+ output.append(nameFormat.form(s1id));
output.append(" (Sequence length = ")
.append(String.valueOf(s1str.length())).append(")")
.append(NEWLINE);
output.append("Sequence ");
output.append(" (Sequence length = ")
.append(String.valueOf(s1str.length())).append(")")
.append(NEWLINE);
output.append("Sequence ");
- output.append(new Format("%" + maxid + "s").form(s2.getName()));
- output.append(" : ").append(String.valueOf(s2.getStart()))
- .append(" - ").append(String.valueOf(s2.getEnd()));
+ output.append(nameFormat.form(s2id));
output.append(" (Sequence length = ")
.append(String.valueOf(s2str.length())).append(")")
.append(NEWLINE).append(NEWLINE);
output.append(" (Sequence length = ")
.append(String.valueOf(s2str.length())).append(")")
.append(NEWLINE).append(NEWLINE);
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
s2str.charAt(j));
float max = score[i - 1][j - 1] + (pairwiseScore * 10);
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
s2str.charAt(j));
float max = score[i - 1][j - 1] + (pairwiseScore * 10);
F[0][0] = 0;
// Calculate the top row first
for (int j = 1; j < m; j++)
{
// What should these values be? 0 maybe
F[0][0] = 0;
// Calculate the top row first
for (int j = 1; j < m; j++)
{
// What should these values be? 0 maybe
- E[0][j] = max(score[0][j - 1] - gapOpen, E[0][j - 1] - gapExtend);
- F[0][j] = -gapExtend;
+ E[0][j] = max(score[0][j - 1] - GAP_OPEN_COST,
+ E[0][j - 1] - GAP_EXTEND_COST);
+ F[0][j] = -GAP_EXTEND_COST;
- E[i][0] = -gapOpen;
- F[i][0] = max(score[i - 1][0] - gapOpen, F[i - 1][0] - gapExtend);
+ E[i][0] = -GAP_OPEN_COST;
+ F[i][0] = max(score[i - 1][0] - GAP_OPEN_COST,
+ F[i - 1][0] - GAP_EXTEND_COST);
- E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - gapExtend);
- F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - gapExtend);
+ E[i][j] = max(score[i][j - 1] - GAP_OPEN_COST,
+ E[i][j - 1] - GAP_EXTEND_COST);
+ F[i][j] = max(score[i - 1][j] - GAP_OPEN_COST,
+ F[i - 1][j] - GAP_EXTEND_COST);
- score[i][j] = max(score[i - 1][j - 1]
- + (pairwiseScore * 10), E[i][j], F[i][j]);
+ score[i][j] = max(score[i - 1][j - 1] + (pairwiseScore * 10),
+ E[i][j], F[i][j]);
float score = (float) (mat[i][j] - min) / (float) (max - min);
g.setColor(new Color(score, 0, 0));
g.fillRect(x, y, psize, psize);
float score = (float) (mat[i][j] - min) / (float) (max - min);
g.setColor(new Color(score, 0, 0));
g.fillRect(x, y, psize, psize);
int pdbpos = s2.getStart() + getSeq2Start() - 2;
int alignpos = s1.getStart() + getSeq1Start() - 2;
int lp2 = pdbpos - 3, lp1 = alignpos - 3;
int pdbpos = s2.getStart() + getSeq2Start() - 2;
int alignpos = s1.getStart() + getSeq1Start() - 2;
int lp2 = pdbpos - 3, lp1 = alignpos - 3;
- int[] mapseq1 = new int[as1.size() + (lastmatch ? 1 : 0)], mapseq2 = new int[as2
- .size() + (lastmatch ? 1 : 0)];
+ int[] mapseq1 = new int[as1.size() + (lastmatch ? 1 : 0)],
+ mapseq2 = new int[as2.size() + (lastmatch ? 1 : 0)];
List<SequenceI> ochains, AlignmentI al, String dnaOrProtein,
boolean removeOldAnnots)
{
List<SequenceI> ochains, AlignmentI al, String dnaOrProtein,
boolean removeOldAnnots)
{