Category Archives: web development

phpmyadmin hybrid install (apt + manual) on Ubuntu

While migrating our websites to the new Ubuntu box, I set up phpmyadmin using apt-get. But that package is 4.5x while the latest version is 4.8x. Not surprisingly, the Nessus security scan needed to get http and https ports opened through the TAMU firewall detected security exploits that I hope have been fixed in the newer versions.

One option would be to just install phpmyadmin directly in /var/www/html. But I wanted to keep all the customization I had already done, and I liked having the config files in locations outside the web root so they can’t be viewed as easily by intruders.

There is probably documentation about the package somewhere, but I don’t know how to find it, so I just dug around and tried stuff to get it to work. Here’s what I figured out and what I did. phpmyadmin from the apt package installs stuff in at least 3 places

  • /usr/share/phpmyadmin – this is the bulk of the codebase
  • /etc/phpmyadmin – conf files for apache and for phpmyadmin
  • /var/lib/phpmyadmin – misc stuff, including the blowfish secret setting and a tmp directory accessible to apache

To get it to work:

  • Downloaded the latest version using wget. I did this in a user directory, but it could be anywhere
  • Rename the directory /usr/share/phpmyadmin to /usr/share/phpmyadmin.apt as a backup. Maybe if the phpmyadmin distro ever catches up we can reactivate it
  • symlink the new version as /usr/share/phpmyadmin
  • write a tiny config.inc.php file to include /etc/phpmyadmin/config.inc.php (this may not get the all the config files, but it seems to work)
  • edit /var/lib/phpmyadmin/blowfish_secret.inc.php to make the string longer
  • edit /usr/share/phpmyadmin/libraries/vendor_config.php to set the tmp dir to /var/lib/phpmyadmin/tmp

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. Giglio, M, Tauber, R, Nadendla, S, Munro, J, Olley, D, Ball, S et al.. ECO, the Evidence & Conclusion Ontology: community standard for evidence information. Nucleic Acids Res. 2018; :. doi: 10.1093/nar/gky1036. PubMed PMID:30407590 .
  2. 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 .
  3. 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 .
  4. 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.
  5. 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.
Search PubMed

ASM format

  1. Giglio, M, Tauber, R, Nadendla, S, Munro, J, Olley, D, Ball, S, Mitraka, E, Schriml, LM, Gaudet, P, Hobbs, ET, Erill, I, Siegele, DA, Hu, JC, Mungall, C, Chibucos, MC. 2018. ECO, the Evidence & Conclusion Ontology: community standard for evidence information. Nucleic Acids Res. :.
  2. Chibucos, MC, Siegele, DA, Hu, JC, Giglio, M. 2017. The Evidence and Conclusion Ontology (ECO): Supporting GO Annotations. Methods Mol. Biol. 1446:245-259.
  3. Gaudet, P, Škunca, N, Hu, JC, Dessimoz, C. 2017. Primer on the Gene Ontology. Methods Mol. Biol. 1446:25-37.
  4. 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.
  5. 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.
Search PubMed

PNAS format

  1. Giglio, M et al.(2018)ECO, the Evidence & Conclusion Ontology: community standard for evidence information. Nucleic Acids Res. :.
  2. Chibucos, MC, Siegele, DA, Hu, JC, Giglio, M(2017)The Evidence and Conclusion Ontology (ECO): Supporting GO Annotations. Methods Mol. Biol. 1446 :245-259.
  3. Gaudet, P, Škunca, N, Hu, JC, Dessimoz, C(2017)Primer on the Gene Ontology. Methods Mol. Biol. 1446 :25-37.
  4. 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.
  5. Chibucos, MC et al.(2014)An ontology for microbial phenotypes. BMC Microbiol. 14 :294.
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.