diff -r f6dd7bd068d0 -r 3c7a90cf71f1 build.xml --- a/build.xml Wed Mar 25 11:40:43 2015 +1000 +++ b/build.xml Thu Apr 09 18:04:23 2015 +1000 @@ -157,11 +157,8 @@ - - - - - + + diff -r f6dd7bd068d0 -r 3c7a90cf71f1 scripts/JsonWr.pm --- a/scripts/JsonWr.pm Wed Mar 25 11:40:43 2015 +1000 +++ b/scripts/JsonWr.pm Thu Apr 09 18:04:23 2015 +1000 @@ -348,7 +348,7 @@ } elsif ($num == 13) { # carriage return $storage .= "\\r"; } else { - $storage .= sprintf("\\u%.04x", $num); + $storage .= sprintf("\\u%04x", $num); } } else { $storage .= $letter; diff -r f6dd7bd068d0 -r 3c7a90cf71f1 src/json-writer.c --- a/src/json-writer.c Wed Mar 25 11:40:43 2015 +1000 +++ b/src/json-writer.c Thu Apr 09 18:04:23 2015 +1000 @@ -197,7 +197,7 @@ // can't have unescaped newline characters in a string. if (codepoint <= 0x1F || (codepoint >= 0x7F && codepoint <= 0x9F) || codepoint == 0x2028 || codepoint == 0x2029) { - str_appendf(storage, "\\u%.04x", codepoint); + str_appendf(storage, "\\u%04x", codepoint); } else { str_append(storage, c, bytes); } diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/css/component_sequences.css --- a/website/css/component_sequences.css Wed Mar 25 11:40:43 2015 +1000 +++ b/website/css/component_sequences.css Thu Apr 09 18:04:23 2015 +1000 @@ -186,6 +186,7 @@ } div.alphainc { + position: relative; display: inline-block; font-variant: small-caps; font-weight: bold; @@ -197,7 +198,25 @@ font-size: x-small; } +div.alphainc > div.mark { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + opacity: 0.3; + color: red; + font-size: 3.5em; +} + +div.alphainc:not(.disallowed) > div.mark { + display: none; +} + div.sequence_input.dna div.alphainc.dna, div.sequence_input.protein div.alphainc.protein { color: DarkGreen; border-color: DarkGreen; } + +div.sequence_input.dna div.alphainc.dna > div.mark, div.sequence_input.protein div.alphainc.protein > div.mark { + opacity: 0.5; +} diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/js/component_sequences.js --- a/website/js/component_sequences.js Wed Mar 25 11:40:43 2015 +1000 +++ b/website/js/component_sequences.js Thu Apr 09 18:04:23 2015 +1000 @@ -118,6 +118,9 @@ // for making XMLHttpRequests this._xml_alph = (options.alphabets.RNA ? 1 : 0) + (options.alphabets.DNA ? 2 : 0) + (options.alphabets.PROTEIN ? 4 : 0); this._xml_short = (options.short_only ? 1 : 0); + // make obvious DNA, Protein allowed / disallowed + toggle_class(container.querySelector("div.alphainc.dna"), "disallowed", !options.alphabets.DNA); + toggle_class(container.querySelector("div.alphainc.protein"), "disallowed", !options.alphabets.PROTEIN); // lookup relevent components this.source = this.container.querySelector("select.sequence_source"); // get the text related parts @@ -490,12 +493,12 @@ xml_doc = request.responseXML; versions = xml_doc.firstChild; // add the other options - all_v = versions.getElementsByTagName("v"); + all_v = versions.getElementsByTagName("version"); for (i = 0; i < all_v.length; i++) { version = all_v[i]; - id = version.getAttribute("i"); - name = version.getAttribute("n"); - alphabets = version.getAttribute("a"); // Bitset where RNA = 1, DNA = 2, PROTEIN = 4 + id = version.getAttribute("id"); + name = version.getAttribute("name"); + alphabets = version.getAttribute("alphabets"); // Bitset where RNA = 1, DNA = 2, PROTEIN = 4 opt = new Option(name, id); opt.setAttribute("data-alphabets", alphabets); optgroup.appendChild(opt); diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/src/au/edu/uq/imb/memesuite/db/SQL.java --- a/website/src/au/edu/uq/imb/memesuite/db/SQL.java Wed Mar 25 11:40:43 2015 +1000 +++ b/website/src/au/edu/uq/imb/memesuite/db/SQL.java Thu Apr 09 18:04:23 2015 +1000 @@ -198,7 +198,7 @@ " INNER JOIN tblSequenceFile as s ON l.id = s.listingId\n" + "WHERE l.categoryId = ? AND s.obsolete = 0 AND (s.alphabet & ?) != 0 AND (NOT ? OR s.maxLen < "+SML+")\n" + " GROUP BY l.id\n" + - "ORDER BY l.name ASC"; + "ORDER BY ltrim(l.name) COLLATE NOCASE ASC"; public static final String SELECT_LISTING = "SELECT name, description\n" + "FROM tblListing WHERE id = ?"; diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/src/au/edu/uq/imb/memesuite/db/SequenceVersion.java --- a/website/src/au/edu/uq/imb/memesuite/db/SequenceVersion.java Wed Mar 25 11:40:43 2015 +1000 +++ b/website/src/au/edu/uq/imb/memesuite/db/SequenceVersion.java Thu Apr 09 18:04:23 2015 +1000 @@ -21,6 +21,14 @@ } } + public String getListingName() { + return sequenceFileMap.values().iterator().next().getListingName(); + } + + public String getListingDescription() { + return sequenceFileMap.values().iterator().next().getListingDescription(); + } + public Set getAlphabets() { return sequenceFileMap.keySet(); } diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/src/au/edu/uq/imb/memesuite/servlet/Glam2Request.java --- a/website/src/au/edu/uq/imb/memesuite/servlet/Glam2Request.java Wed Mar 25 11:40:43 2015 +1000 +++ b/website/src/au/edu/uq/imb/memesuite/servlet/Glam2Request.java Thu Apr 09 18:04:23 2015 +1000 @@ -82,6 +82,47 @@ out.output(resp.getWriter()); } + protected void comparePwm(HttpServletRequest req, HttpServletResponse resp, + int index) throws ServletException, IOException { + String alphabet = WebUtils.paramChoice(req, "alphabet", "n", "p"); + boolean both_strands = WebUtils.paramBool(req, "-2"); + String pspm = WebUtils.paramRequire(req, "pspm" + index); + StringBuilder builder = new StringBuilder(); + builder.append("\nMEME version 4\n\n"); + builder.append("ALPHABET= "); + builder.append(alphabet.equals("n") ? "ACGT" : "ACDEFGHIKLMNPQRSTVWY"); + builder.append("\n\n"); + if (alphabet.equals("n")) { + if (both_strands) { + builder.append("strands: + -\n\n"); + } else { + builder.append("strands: +\n\n"); + } + } + builder.append("Background letter frequencies (from uniform background):\n"); + if (alphabet.equals("n")) { + builder.append("A 0.25 C 0.25 G 0.25 T 0.25"); + } else { + builder.append("A 0.05 C 0.05 D 0.05 E 0.05 F 0.05 G 0.05 H 0.05 I 0.05 K 0.05 L 0.05 M 0.05 N 0.05 P 0.05 Q 0.05 R 0.05 S 0.05 T 0.05 V 0.05 W 0.05 Y 0.05"); + } + builder.append("\n\n"); + builder.append("MOTIF "); + builder.append(index); + builder.append(" GLAM2\n"); + builder.append(pspm); + builder.append("\n"); + + HTMLTemplate parameter = tmplRequestRedirect.getSubtemplate("parameter"); + HTMLSub out = tmplRequestRedirect.toSub(); + out.set("tool", "tomtom"); + List parameters = new ArrayList(); + parameters.add(parameter.toSub().set("name", "motifs_embed"). + set("value", WebUtils.escapeHTML(builder.toString()))); + out.set("parameter", parameters); + resp.setContentType("text/html"); + out.output(resp.getWriter()); + } + protected void rerunGlam2(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { HTMLTemplate parameter = tmplRequestRedirect.getSubtemplate("parameter"); @@ -139,6 +180,7 @@ HttpServletResponse resp) throws ServletException, IOException { Pattern scanAlnRE = Pattern.compile("^Scan alignment (\\d+)"); Pattern viewAlnOrPSPMRE = Pattern.compile("^View (alignment|PSPM) (\\d+)"); + Pattern comparePwmRE = Pattern.compile("^(?:Compare|COMPARE) PSPM (\\d+)"); Matcher match; String action = req.getParameter("action"); if (action == null) { @@ -151,6 +193,8 @@ scanAln(req, resp, Integer.parseInt(match.group(1), 10)); } else if (action.contains("re-run GLAM2")) { rerunGlam2(req, resp); + } else if ((match = comparePwmRE.matcher(action)).matches()) { + comparePwm(req, resp, Integer.parseInt(match.group(1), 10)); } else if ( action.equals("MAST") || action.matches("^MAST PSSM \\d+") || @@ -163,8 +207,6 @@ action.matches("^Submit BLOCK \\d+") || action.matches("^View \\w+ \\d+") || action.matches("^TOMTOM PSPM \\d+") || - action.matches("^Compare PSPM \\d+") || - action.matches("^COMPARE PSPM \\d+") || action.startsWith("View motif summary") || action.contains("MetaMEME") || action.contains("MEME Man Page") || diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/src/au/edu/uq/imb/memesuite/servlet/ShowSequenceDBs.java --- a/website/src/au/edu/uq/imb/memesuite/servlet/ShowSequenceDBs.java Wed Mar 25 11:40:43 2015 +1000 +++ b/website/src/au/edu/uq/imb/memesuite/servlet/ShowSequenceDBs.java Thu Apr 09 18:04:23 2015 +1000 @@ -15,8 +15,10 @@ import java.io.IOException; import java.io.PrintWriter; import java.sql.SQLException; +import java.util.Collections; import java.util.EnumSet; import java.util.Iterator; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -29,10 +31,7 @@ public class ShowSequenceDBs extends HttpServlet { private ServletContext context; private HTMLTemplate template; - private HTMLTemplate categoryLiTemplate; private HTMLTemplate categoryTemplate; - private HTMLTemplate listingTemplate; - private HTMLTemplate versionTemplate; private static Logger logger = Logger.getLogger("au.edu.uq.imb.memesuite.web.sequencedb"); @@ -43,10 +42,7 @@ this.context = this.getServletContext(); HTMLTemplateCache cache = (HTMLTemplateCache)context.getAttribute(CACHE_KEY); template = cache.loadAndCache("/WEB-INF/templates/show_sequence_dbs.tmpl"); - categoryLiTemplate = template.getSubtemplate("content").getSubtemplate("category_li"); - categoryTemplate = template.getSubtemplate("content").getSubtemplate("category"); - listingTemplate = categoryTemplate.getSubtemplate("listing"); - versionTemplate = listingTemplate.getSubtemplate("version"); + categoryTemplate = template.getSubtemplate("category"); } @Override @@ -76,8 +72,7 @@ HTMLSub out = template.toSub(); if (sequenceDBList != null) { try { - out.getSub("content").set("category_li", new AllCategoryList(sequenceDBList)); - out.getSub("content").set("category", new AllCategories(sequenceDBList)); + out.set("category", new AllCategory(sequenceDBList)); } catch (SQLException e) { logger.log(Level.SEVERE, "Error loading sequence categories", e); out.empty("content"); @@ -158,6 +153,36 @@ } } + private String escapeXMLAttribute(String value) { + StringBuilder out = new StringBuilder(value); + for (int i = 0; i < out.length();) { + String rep; + switch (out.charAt(i)) { + case '<': + rep = "<"; + break; + case '>': + rep = ">"; + break; + case '"': + rep = """; + break; + case '&': + rep = "&"; + break; + case '\'': + rep = "'"; + break; + default: + i++; + continue; + } + out.replace(i, i+1, rep); + i += rep.length(); + } + return out.toString(); + } + private void outputXmlVersionsOfListing(HttpServletResponse response, long listingId, boolean shortOnly, EnumSet allowedAlphabets) throws IOException, ServletException { @@ -165,16 +190,33 @@ response.setContentType("application/xml"); PrintWriter out = null; try { - Iterator versionView = sequenceDBList.getVersions(listingId, shortOnly, allowedAlphabets).iterator(); + List versions = sequenceDBList.getVersions(listingId, shortOnly, allowedAlphabets); + String listingName = ""; + String listingDescription = ""; + if (!versions.isEmpty()) { + SequenceVersion ver = versions.get(0); + listingName = ver.getListingName(); + listingDescription = ver.getListingDescription(); + } out = response.getWriter(); - out.println(""); - while (versionView.hasNext()) { - SequenceVersion version = versionView.next(); - out.println(""); + out.println(""); + for (SequenceVersion version : versions) { + out.println(""); + for (Alphabet alphabet : version.getAlphabets()) { + SequenceDB file = version.getSequenceFile(alphabet); + out.println(""); + } + out.println(""); } out.println(""); } catch (SQLException e) { @@ -185,95 +227,16 @@ } - private class AllCategoryList extends HTMLSubGenerator { - private AllCategoryList(SequenceDBList sequenceDBList) throws SQLException{ + private class AllCategory extends HTMLSubGenerator { + private AllCategory(SequenceDBList sequenceDBList) throws SQLException{ super(sequenceDBList.getCategories(false, EnumSet.allOf(Alphabet.class))); } @Override protected HTMLSub transform(Category item) { - HTMLSub out = categoryLiTemplate.toSub(); - out.set("id", item.getID()); - out.set("name", item.getName()); - return out; - } - } - - private class AllCategories extends HTMLSubGenerator { - private SequenceDBList sequenceDBList; - - private AllCategories(SequenceDBList sequenceDBList) throws SQLException{ - super(sequenceDBList.getCategories(false, EnumSet.allOf(Alphabet.class))); - this.sequenceDBList = sequenceDBList; - } - - @Override - protected HTMLSub transform(Category item) { HTMLSub out = categoryTemplate.toSub(); out.set("id", item.getID()); out.set("name", item.getName()); - try { - out.set("listing", new AllListingsOfCategory(sequenceDBList, item.getID())); - } catch (SQLException e) { - logger.log(Level.SEVERE, "Error loading sequence listings", e); - out.empty("listing"); - } - return out; - } - } - - private class AllListingsOfCategory extends HTMLSubGenerator { - private SequenceDBList sequenceDBList; - - public AllListingsOfCategory(SequenceDBList sequenceDBList, long id) throws SQLException { - super(sequenceDBList.getListings(id)); - this.sequenceDBList = sequenceDBList; - } - - @Override - protected HTMLSub transform(Listing listing) { - HTMLSub out = listingTemplate.toSub(); - out.set("name", listing.getName()); - out.set("description", listing.getDescription()); - try { - out.set("version", new AllVersionsOfListing(sequenceDBList, listing.getID())); - } catch (SQLException e) { - logger.log(Level.SEVERE, "Error loading sequence versions", e); - out.empty("version"); - } - EnumSet alphabets = listing.getAlphabets(); - if (!alphabets.contains(Alphabet.RNA)) out.empty("rna"); - if (!alphabets.contains(Alphabet.DNA)) out.empty("dna"); - if (!alphabets.contains(Alphabet.PROTEIN)) out.empty("protein"); - return out; - } - } - - private class AllVersionsOfListing extends HTMLSubGenerator { - private AllVersionsOfListing(SequenceDBList sequenceDBList, long listingId) throws SQLException { - super(sequenceDBList.getVersions(listingId)); - } - - @Override - protected HTMLSub transform(SequenceVersion listing) { - SequenceDB sequenceDB; - HTMLSub out = versionTemplate.toSub(); - out.set("name", listing.getVersion()); - if ((sequenceDB = listing.getSequenceFile(Alphabet.DNA)) != null) { - out.getSub("dna").set("description", sequenceDB.getDescription()); - } else { - out.empty("dna"); - } - if ((sequenceDB = listing.getSequenceFile(Alphabet.RNA)) != null) { - out.getSub("rna").set("description", sequenceDB.getDescription()); - } else { - out.empty("rna"); - } - if ((sequenceDB = listing.getSequenceFile(Alphabet.PROTEIN)) != null) { - out.getSub("protein").set("description", sequenceDB.getDescription()); - } else { - out.empty("protein"); - } return out; } } diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/src/au/edu/uq/imb/memesuite/servlet/SubmitJob.java --- a/website/src/au/edu/uq/imb/memesuite/servlet/SubmitJob.java Wed Mar 25 11:40:43 2015 +1000 +++ b/website/src/au/edu/uq/imb/memesuite/servlet/SubmitJob.java Thu Apr 09 18:04:23 2015 +1000 @@ -689,12 +689,15 @@ protected UUID requestUniqueId(HttpServletRequest request) { UUID uuid = null; - for (Cookie cookie : request.getCookies()) { - if (cookie.getName().equals("meme_uuid")) { - try { - uuid = UUID.fromString(cookie.getValue()); - } catch (IllegalArgumentException e) { - break; + Cookie[] cookies = request.getCookies(); + if (cookies != null) { // returns null when no cookies (really stupid design in my opinion) + for (Cookie cookie : cookies) { + if (cookie.getName().equals("meme_uuid")) { + try { + uuid = UUID.fromString(cookie.getValue()); + } catch (IllegalArgumentException e) { + break; + } } } } diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/src/au/edu/uq/imb/memesuite/updatedb/GenbankUpdater.java --- a/website/src/au/edu/uq/imb/memesuite/updatedb/GenbankUpdater.java Wed Mar 25 11:40:43 2015 +1000 +++ b/website/src/au/edu/uq/imb/memesuite/updatedb/GenbankUpdater.java Thu Apr 09 18:04:23 2015 +1000 @@ -283,7 +283,7 @@ } public String toString() { - return "GenBank v" + version + " " + id.replace('_', ' ') + " (" + alphabet + ")"; + return "GenBank v" + version + " " + id.replace('_', ' ').trim() + " (" + alphabet + ")"; } @Override @@ -298,12 +298,12 @@ @Override public String getListingName() { - return id.replace('_', ' '); + return id.replace('_', ' ').trim(); } @Override public String getListingDescription() { - return "Sequences from GenBank for " + id.replace('_', ' ') + "."; + return "Sequences from GenBank for " + id.replace('_', ' ').trim() + "."; } @Override diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/src/au/edu/uq/imb/memesuite/util/JsonWr.java --- a/website/src/au/edu/uq/imb/memesuite/util/JsonWr.java Wed Mar 25 11:40:43 2015 +1000 +++ b/website/src/au/edu/uq/imb/memesuite/util/JsonWr.java Thu Apr 09 18:04:23 2015 +1000 @@ -158,7 +158,7 @@ // can't have unescaped newline characters in a string. if (codepoint <= 0x1F || (codepoint >= 0x7F && codepoint <= 0x9F) || codepoint == 0x2028 || codepoint == 0x2029) { - substitute = String.format("\\u%.04x", codepoint); + substitute = String.format("\\u%04x", codepoint); cols += 6; } else { cols++; diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/templates/component_sequences.tmpl --- a/website/templates/component_sequences.tmpl Wed Mar 25 11:40:43 2015 +1000 +++ b/website/templates/component_sequences.tmpl Thu Apr 09 18:04:23 2015 +1000 @@ -104,7 +104,7 @@ - DNA Protein + DNA✗ Protein✗ diff -r f6dd7bd068d0 -r 3c7a90cf71f1 website/templates/show_sequence_dbs.tmpl --- a/website/templates/show_sequence_dbs.tmpl Wed Mar 25 11:40:43 2015 +1000 +++ b/website/templates/show_sequence_dbs.tmpl Thu Apr 09 18:04:23 2015 +1000 @@ -11,34 +11,76 @@ @@ -208,50 +377,36 @@ Sequence Databases - - Categories - - A Category - - Databases - - - A Category - - - - A Listing - - A description of the listing will go here. It - will be about two or three sentences long. - - Versions: - - - Version Name - - This is a description of the DNA version. - - This is a description of the RNA version. - - This is a description of the protein version. - - - Alphabets: - - DNA - RNA - Protein - - - - - - + Click a category to show its available databases. Within a category click a database to see details. + + + + A Category + + ... + ▼ - + Loading... - + +
A description of the listing will go here. It - will be about two or three sentences long.
Click a category to show its available databases. Within a category click a database to see details.