Category Archives: web development

JSmol2wp plugin released at wordpress.org

A while ago I wrote a WordPress shortcode plugin to embed Bob Hanson’s JSmol molecular structure viewer into WordPress posts and pages. Last weekend I finally got it into the wordpress.org plugin repository.

The basic usage for proteins is via a shortcode like this:

[jsmol pdb='1LMB']

The plugin fetches the appropriate record from the PDB and generates an applet like this:


About/Help

If you use acc key and prefix a chemical name with a $, JSmol looks looks for the structure at NCI.

[jsmol acc=$tryptophan]


About/Help

You can rotate and zoom the structure with your mouse. These default buttons in the applet are created automatically by the plugin, or you can add custom buttons that run Jmol scripts. Using the outstanding flexibility built into Bob’s code (I just wrapped it for WordPress), you can fetch small molecules from remote repositories, or load files uploaded to your WordPress installation. The plugin whitelists pdb, cif, cml, jvxl, mol, mol2, xyz, and ccp4 filetypes for upload (this might be problematic for some hosting providers).Click the About/Help link to see more examples and documentation.

WP PubMed Reflist

I committed a couple of updates to my WordPress plugin for getting reference lists from PubMed. The new version allows customization of the display. I preloaded some templates that approximate a few popular formats

NIH format

  1. Chibucos, MC, Siegele, DA, Hu, JC, Giglio, M. The Evidence and Conclusion Ontology (ECO): Supporting GO Annotations. Methods Mol. Biol. 2017;1446 :245-259. doi: 10.1007/978-1-4939-3743-1_18. PubMed PMID:27812948 .
  2. Gaudet, P, Škunca, N, Hu, JC, Dessimoz, C. Primer on the Gene Ontology. Methods Mol. Biol. 2017;1446 :25-37. doi: 10.1007/978-1-4939-3743-1_3. PubMed PMID:27812933 .
  3. Nehring, RB, Gu, F, Lin, HY, Gibson, JL, Blythe, MJ, Wilson, R et al.. An ultra-dense library resource for rapid deconvolution of mutations that cause phenotypes in Escherichia coli. Nucleic Acids Res. 2016;44 (5):e41. doi: 10.1093/nar/gkv1131. PubMed PMID:26578563 PubMed Central PMC4797258.
  4. Chibucos, MC, Zweifel, AE, Herrera, JC, Meza, W, Eslamfam, S, Uetz, P et al.. An ontology for microbial phenotypes. BMC Microbiol. 2014;14 :294. doi: 10.1186/s12866-014-0294-3. PubMed PMID:25433798 PubMed Central PMC4287307.
  5. Hu, JC, Sherlock, G, Siegele, DA, Aleksander, SA, Ball, CA, Demeter, J et al.. PortEco: a resource for exploring bacterial biology through high-throughput data and analysis tools. Nucleic Acids Res. 2014;42 (Database issue):D677-84. doi: 10.1093/nar/gkt1203. PubMed PMID:24285306 PubMed Central PMC3965092.
Search PubMed

ASM format

  1. Chibucos, MC, Siegele, DA, Hu, JC, Giglio, M. 2017. The Evidence and Conclusion Ontology (ECO): Supporting GO Annotations. Methods Mol. Biol. 1446:245-259.
  2. Gaudet, P, Škunca, N, Hu, JC, Dessimoz, C. 2017. Primer on the Gene Ontology. Methods Mol. Biol. 1446:25-37.
  3. Nehring, RB, Gu, F, Lin, HY, Gibson, JL, Blythe, MJ, Wilson, R, Bravo Núñez, MA, Hastings, PJ, Louis, EJ, Frisch, RL, Hu, JC, Rosenberg, SM. 2016. An ultra-dense library resource for rapid deconvolution of mutations that cause phenotypes in Escherichia coli. Nucleic Acids Res. 44:e41.
  4. Chibucos, MC, Zweifel, AE, Herrera, JC, Meza, W, Eslamfam, S, Uetz, P, Siegele, DA, Hu, JC, Giglio, MG. 2014. An ontology for microbial phenotypes. BMC Microbiol. 14:294.
  5. Hu, JC, Sherlock, G, Siegele, DA, Aleksander, SA, Ball, CA, Demeter, J, Gouni, S, Holland, TA, Karp, PD, Lewis, JE, Liles, NM, McIntosh, BK, Mi, H, Muruganujan, A, Wymore, F, Thomas, PD, Altman, T. 2014. PortEco: a resource for exploring bacterial biology through high-throughput data and analysis tools. Nucleic Acids Res. 42:D677-84.
Search PubMed

PNAS format

  1. Chibucos, MC, Siegele, DA, Hu, JC, Giglio, M(2017)The Evidence and Conclusion Ontology (ECO): Supporting GO Annotations. Methods Mol. Biol. 1446 :245-259.
  2. Gaudet, P, Škunca, N, Hu, JC, Dessimoz, C(2017)Primer on the Gene Ontology. Methods Mol. Biol. 1446 :25-37.
  3. Nehring, RB et al.(2016)An ultra-dense library resource for rapid deconvolution of mutations that cause phenotypes in Escherichia coli. Nucleic Acids Res. 44 (5):e41.
  4. Chibucos, MC et al.(2014)An ontology for microbial phenotypes. BMC Microbiol. 14 :294.
  5. Hu, JC et al.(2014)PortEco: a resource for exploring bacterial biology through high-throughput data and analysis tools. Nucleic Acids Res. 42 (Database issue):D677-84.
Search PubMed

Notes

The formatting options in 0.7+ allow handling of long author lists to give et al. were there are too many authors.

Because I do WordPress development only sporadically, I made some errors in the 0.7 release. I do my testing on my Mac, where unfortunately I set my laptop up to have case-insensitive filenames, and had a uppercase vs lowercase filename error in the subversion commit for 0.7. When fixing the filenames on a Mac, you can’t just use svn mv filename fileName. You get an uninformative error. You have to do it in two steps doing something like this:

  • svn mv filename filename.tmp
  • svn mv filename.tmp fileName

Your spambot needs debugging

Found an amusing spam in my comment moderation queue. Excerpt:

{
{I have|I’ve} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I
never found any interesting article like yours.

{It’s|It is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all
{webmasters|site owners|website owners|web owners} and
bloggers made good content as you did, the {internet|net|web} will be {much more|a lot more} useful than ever before.|
I {couldn’t|could not} {resist|refrain from} commenting.
{Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I’ll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can’t} {in finding|find|to find}
your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service.
Do {you have|you’ve} any? {Please|Kindly} {allow|permit|let}
me {realize|recognize|understand|recognise|know} {so
that|in order that} I {may just|may|could} subscribe.
Thanks.|

WordPress shortcode plugins with multiple instances

I’ve been working on the JSmol2wp plugin used in these previous posts. There have been a couple of challenges associated with putting multiple copies of the JSmol viewer applet in the same post, and in having multiple posts with viewers.

The WordPress shortcode API doesn’t provide an obvious way for a shortcode to know its position in a post. For most shortcodes, this doesn’t matter; they return content to WordPress to put in place of the shortcode. The reason it’s important for JSmol2wp (and perhaps to other plugin developers) is that JSmol2wp needs to assign each applet a unique identifier so that commands are channeled to the correct applet. Googling “wordpress shortcode multiple instances” reveals other developers having the same problem.

My solution(s)

Various versions of JSmol2wp used variations on the same solution based on the idea that knowing the integer value for which copy of the shortcode I had is valuable. In hindsight, there are two easier solutions:

  • create a unique id that does not depend on anything else, based on something like a timestamp or an md5 of various passed parameters
  • make the user encode the uniqueID (I don’t like this one, but I ended up having it available as a fallback

The solution I used is to pull the entire content of the post and search for the shortcode markup  using either string functions or regexes. The current version is clunky because I was not sure whether PCRE was causing problems for some installations.

$p = get_post();
# determine the instance if there are multiple copies
# of the shortcode in this post
# we want to do this without preg_match to work on different PHP versions
$m = explode('[jsmol', get_the_content());
array_shift($m);
foreach($m as $i => $match){
     $t = explode(']', $match);
     # there could be nested shortcodes or other shortcodes in the text
     # but trim off what is safe to trim off
     if(count($t) > 1){
        array_pop($t);
        $match = implode(']]', $t);
     }
     # odd bug requires recasting as a string to get stripos to work
     $match = (string)$match;
     # catenate the post_id to the instance to make the id unique
     # when displaying multiple posts per page
     if( ($acc == '' || stripos($match, $acc) > 0 ) &&
        ($caption == '' || stripos($match, $caption) > 0) &&
        ($fileURL == '' || stripos($match, $fileURL) > 0) &&
        ($isosurface == '' || stripos($match, $isosurface) > 0) &&
        ($id == '' || stripos($match, $id) > 0)
     ) $this->instance = $p->ID."_$i";
}

This would be better with the right regex, but my regex skills are not that good at thinking about how to handle the possibility of [ and ] inside the parameters passed by the shortcode, since these are legal characters in Jmol scripting.

Note that the unique id includes the post ID. This prevents clashes when multiple posts are displayed on a single page.

The

 # odd bug requires recasting as a string to get stripos to work
$match = (string)$match;

was to fix a problem where spaces in one of the parameters (caption) caused stripos to return false, even though var_dump showed $match was already a string.

More JSmol2wp testing

As of version 0.7, I wonder whether having two posts with viewers causes applet name clashes. The prediction is that this would work while viewing one post, but not on the home page. This prediction turned out to be true.

This first item loaded the first one from the next post, while the first item in the next post didn’t load. Should work now in 0.8

Load 1PRC

About/Help

Load file from Henry Rzepa's blog

About/Help

 

Updating to Mavericks Server

We have a mini that we got to support a program to train undergrads in bioinformatics. Over the past week or so I’ve been working on updating it to run Mavericks and Mavericks Server.  I first decided to go with OSX servers back when I had a G5 blade running Panther Server for the user-friendly GUI management system. But since then OSX server has gotten to be steadily more annoying in that:

  • The Server and Server Admin apps have never been backward compatible with earlier versions. This means I have to do remote administration of older machines – some of which cannot be updated to the latest OK – through either ssh or vnc. The former defeats the purpose of having the GUI. The latter is sluggish.
  • The amount of control the admin gets over things has been steadily declining. In the first versions of Server, there that gave you pretty fine-grained control over configuration. That’s all gone.

So, as with Lion Server, which is what I’m upgrading from, I think I’m going to end up running everything via MacPorts, and not use the Server.app. Or look into converting it to a Linux Box.

Weird, given Marissa Mayer’s rep from Google

I first heard of Marissa Mayer from a podcast of this talk from the Stanford Entrepreneurial Thought Leaders series.  As I recall, one of the intereresting things was the way Google tested UI options and gathered data about what did or did not work for users. Given that, I am kind of surprised how hideous the Yahoo Sports Blog pages have become.

John Gruber links to criticism of the new logo; this goes way beyond logo fonts.

Fix for Macports 2.2.0 upgrade problems (if /opt/local is a symlink)

I was having trouble updating MacPorts on one of our OSX servers.

Error: org.macports.extract for port gnupg returned: command execution failed
Please see the log file for port gnupg for details:
    /opt/local/var/macports/logs/_Volumes_r4_opt_local_var_macports_sources_rsync.macports.org_release_ports_mail_gnupg/gnupg/main.log
Error: Unable to upgrade port: 1
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets

It turns out that version 2.2.0 doesn’t like symlinks to /opt/local that didn’t bother earlier versions.  See here.  The solution was to edit /opt/local/etc/macports/macports.conf in order to provide the full path everywhere.

 

WP PubMed Reflist

One of the reasons I started my old blog was to use it as a front end for managing our department website.  Prospective graduate students generally don’t think my friends at MIT haven’t published for the last 5 years based on their website, but people with bicoastal biases might actually believe that about Texas A&M.  Manual updates are a pain.  Faculty send you information in different formats, when they bother to respond at all.

baker pubs July 2013

 

When I was in charge of graduate recruiting, I also wrote some PHP scripts to automate the management of our departmental website, in an attempt to break the cycle of revision via Dreamweaver.  One of the features I was most proud of was automated updates of faculty publication lists from PubMed via NCBI’s EUtils web service.  Now that we’ve migrated to WordPress, I wrote a wordpress plugin WP PubMed Reflist to supply that functionality.  I’ve now made it available on WordPress.org and I was pleased to see that the updater here pulled the latest update, which adds PMC and Full Text links.

For comparison, Tania Baker’s website at biology.mit.edu as of today: vs what the plugin does:

  1. Baytshtok, V, Chen, J, Glynn, SE, Nager, AR, Grant, RA, Baker, TA et al.. Covalently linked HslU hexamers support a probabilistic mechanism that links ATP hydrolysis to protein unfolding and translocation. J. Biol. Chem. 2017;292 (14):5695-5704. doi: 10.1074/jbc.M116.768978. PubMed PMID:28223361 PubMed Central PMC5392565.
  2. Hall, BM, Breidenstein, EB, de la Fuente-Núñez, C, Reffuveille, F, Mawla, GD, Hancock, RE et al.. Two isoforms of Clp peptidase in Pseudomonas aeruginosa control distinct aspects of cellular physiology. J. Bacteriol. 2016; :. doi: 10.1128/JB.00568-16. PubMed PMID:27849175 PubMed Central PMC5237113.
  3. Baytshtok, V, Fei, X, Grant, RA, Baker, TA, Sauer, RT. A Structurally Dynamic Region of the HslU Intermediate Domain Controls Protein Degradation and ATP Hydrolysis. Structure. 2016;24 (10):1766-1777. doi: 10.1016/j.str.2016.08.012. PubMed PMID:27667691 PubMed Central PMC5061557.
  4. Amor, AJ, Schmitz, KR, Sello, JK, Baker, TA, Sauer, RT. Highly Dynamic Interactions Maintain Kinetic Stability of the ClpXP Protease During the ATP-Fueled Mechanical Cycle. ACS Chem. Biol. 2016;11 (6):1552-60. doi: 10.1021/acschembio.6b00083. PubMed PMID:27003103 PubMed Central PMC5087277.
  5. Stein, BJ, Grant, RA, Sauer, RT, Baker, TA. Structural Basis of an N-Degron Adaptor with More Stringent Specificity. Structure. 2016;24 (2):232-42. doi: 10.1016/j.str.2015.12.008. PubMed PMID:26805523 PubMed Central PMC4979544.
Search PubMed