X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FUniprot.java;h=167cd977d325a06d6ddf2d2128053715ecb772d6;hb=743af46c3c50e67706009be4360fa504bfcd4fdc;hp=6b09eb6ebc6f5700528243dd850ae872202a9770;hpb=f87f3bc59e76f6112821e01ed88cf4c3ed853379;p=jalview.git diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 6b09eb6..167cd97 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -32,6 +32,8 @@ import jalview.datamodel.SequenceI; import jalview.datamodel.xdb.uniprot.UniprotEntry; import jalview.datamodel.xdb.uniprot.UniprotFeature; import jalview.datamodel.xdb.uniprot.UniprotFile; +import jalview.schemes.ResidueProperties; +import jalview.util.StringUtils; import jalview.ws.seqfetcher.DbSourceProxyImpl; import java.io.InputStream; @@ -40,6 +42,7 @@ import java.io.Reader; import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; +import java.util.List; import java.util.Vector; import org.exolab.castor.mapping.Mapping; @@ -278,7 +281,7 @@ public class Uniprot extends DbSourceProxyImpl for (UniprotFeature uf : entry.getFeature()) { SequenceFeature copy = new SequenceFeature(uf.getType(), - uf.getDescription(), uf.getBegin(), uf.getEnd(), "Uniprot"); + getDescription(uf), uf.getBegin(), uf.getEnd(), "Uniprot"); copy.setStatus(uf.getStatus()); sequence.addSequenceFeature(copy); } @@ -291,6 +294,94 @@ public class Uniprot extends DbSourceProxyImpl } /** + * Constructs a feature description from the description and (optionally) + * original and variant fields of the Uniprot XML feature + * + * @param uf + * @return + */ + protected static String getDescription(UniprotFeature uf) + { + String orig = uf.getOriginal(); + List variants = uf.getVariation(); + StringBuilder sb = new StringBuilder(); + + /* + * append variant in standard format if present + * e.g. p.Arg59Lys + * multiple variants are split over lines using
+ */ + boolean asHtml = false; + if (orig != null && !orig.isEmpty() && variants != null + && !variants.isEmpty()) + { + int p = 0; + for (String var : variants) + { + // TODO proper HGVS nomenclature for delins structural variations + // http://varnomen.hgvs.org/recommendations/protein/variant/delins/ + // for now we are pragmatic - any orig/variant sequence longer than + // three characters is shown with single-character notation rather than + // three-letter notation + sb.append("p."); + if (orig.length() < 4) + { + for (int c = 0, clen = orig.length(); c < clen; c++) + { + char origchar = orig.charAt(c); + String orig3 = ResidueProperties.aa2Triplet.get("" + origchar); + sb.append(orig3 == null ? origchar + : StringUtils.toSentenceCase(orig3)); + } + } + else + { + sb.append(orig); + } + + sb.append(Integer.toString(uf.getPosition())); + + if (var.length() < 4) + { + for (int c = 0, clen = var.length(); c < clen; c++) + { + char varchar = var.charAt(c); + String var3 = ResidueProperties.aa2Triplet.get("" + varchar); + + sb.append(var3 != null ? StringUtils.toSentenceCase(var3) + : "" + varchar); + } + } + else + { + sb.append(var); + } + if (++p != variants.size()) + { + sb.append("
  "); + asHtml = true; + } + else + { + sb.append(" "); + } + } + } + String description = uf.getDescription(); + if (description != null) + { + sb.append(description); + } + if (asHtml) + { + sb.insert(0, ""); + sb.append(""); + } + + return sb.toString(); + } + + /** * * @param entry * UniportEntry