package jalview.ws.sifts;
import jalview.analysis.AlignSeq;
+import jalview.analysis.scoremodels.ScoreMatrix;
+import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.DBRefEntryI;
import jalview.api.SiftsClientI;
import jalview.datamodel.DBRefEntry;
.equalsIgnoreCase(seqCoordSys.getName())
&& isAccessionMatched(cRefDb.getDbAccessionId()))
{
- String resNumIndexString = cRefDb.getDbResNum()
- .equalsIgnoreCase("None") ? String.valueOf(UNASSIGNED)
- : cRefDb.getDbResNum();
- try
- {
- currSeqIndex = Integer.valueOf(resNumIndexString);
- } catch (NumberFormatException nfe)
- {
- currSeqIndex = Integer.valueOf(resNumIndexString
- .split("[a-zA-Z]")[0]);
- continue;
- }
+ currSeqIndex = getLeadingIntegerValue(
+ cRefDb.getDbResNum(), UNASSIGNED);
if (pdbRefDb != null)
{
break;// exit loop if pdb and uniprot are already found
}
if (currSeqIndex >= seq.getStart() && currSeqIndex <= seq.getEnd())
{
- int resNum;
- try
- {
- resNum = (pdbRefDb == null) ? Integer.valueOf(residue
- .getDbResNum()) : Integer.valueOf(pdbRefDb
- .getDbResNum());
- } catch (NumberFormatException nfe)
- {
- if (pdbRefDb == null || pdbRefDb.getDbResNum().equals("null"))
- {
- resNum = UNASSIGNED;
- continue;
- }
- resNum = Integer.valueOf(pdbRefDb
- .getDbResNum().split("[a-zA-Z]")[0]);
- continue;
- }
+
+ int resNum = (pdbRefDb == null) ? getLeadingIntegerValue(
+ residue.getDbResNum(), UNASSIGNED)
+ : getLeadingIntegerValue(pdbRefDb.getDbResNum(),
+ UNASSIGNED);
if (isResidueObserved(residue)
|| seqCoordSys == CoordinateSys.UNIPROT)
}
/**
+ * Get the leading integer part of a string that begins with an integer.
+ *
+ * @param input
+ * - the string input to process
+ * @param failValue
+ * - value returned if unsuccessful
+ * @return
+ */
+ static int getLeadingIntegerValue(String input, int failValue)
+ {
+ if (input == null)
+ {
+ return failValue;
+ }
+ String[] parts = input.split("(?=\\D)(?<=\\d)");
+ if (parts != null && parts.length > 0 && parts[0].matches("[0-9]+"))
+ {
+ return Integer.valueOf(parts[0]);
+ }
+ return failValue;
+ }
+
+
+ /**
*
* @param chainId
* Target chain to populate mapping of its atom positions.
}
@Override
- public StringBuffer getMappingOutput(MappingOutputPojo mp)
+ public StringBuilder getMappingOutput(MappingOutputPojo mp)
throws SiftsException
{
String seqRes = mp.getSeqResidue();
int nochunks = ((seqRes.length()) / len)
+ ((seqRes.length()) % len > 0 ? 1 : 0);
// output mappings
- StringBuffer output = new StringBuffer();
+ StringBuilder output = new StringBuilder(512);
output.append(NEWLINE);
output.append("Sequence \u27f7 Structure mapping details").append(
NEWLINE);
output.append(String.valueOf(pdbEnd));
output.append(NEWLINE).append(NEWLINE);
+ ScoreMatrix pam250 = ScoreModels.getInstance().getPam250();
int matchedSeqCount = 0;
for (int j = 0; j < nochunks; j++)
{
output.append(NEWLINE);
output.append(new Format("%" + (maxid) + "s").form(" ")).append(" ");
- // Print out the matching chars
+ /*
+ * Print out the match symbols:
+ * | for exact match (ignoring case)
+ * . if PAM250 score is positive
+ * else a space
+ */
for (int i = 0; i < len; i++)
{
try
{
if ((i + (j * len)) < seqRes.length())
{
- boolean sameChar = Comparison.isSameResidue(
- seqRes.charAt(i + (j * len)),
- strRes.charAt(i + (j * len)), false);
- if (sameChar
- && !jalview.util.Comparison.isGap(seqRes.charAt(i
- + (j * len))))
+ char c1 = seqRes.charAt(i + (j * len));
+ char c2 = strRes.charAt(i + (j * len));
+ boolean sameChar = Comparison.isSameResidue(c1, c2, false);
+ if (sameChar && !Comparison.isGap(c1))
{
matchedSeqCount++;
output.append("|");
}
else if (type.equals("pep"))
{
- if (ResidueProperties.getPAM250(seqRes.charAt(i + (j * len)),
- strRes.charAt(i + (j * len))) > 0)
+ if (pam250.getPairwiseScore(c1, c2) > 0)
{
output.append(".");
}