Sunday, 18 December 2011

The Very Simple JavaScript Formula Class

A small Javascript program I wrote a while back but didn't get round to releasing until now.

The Very Simple JavaScript Formula class takes a simple string of characters written with a standard keyboard and translates it into HTML code that attempts to visually represent the mathematical notation. The purpose of this class is to make maths on the web easier to write, display and understand - users won't need to learn LaTeX or other markup languages or use desktop/server-side applications to create visual Formulas. All you need to do now is type the formula and VSJSFormula will display the rendered formula. The source code is at:
http://code.google.com/p/vsjsformula/

Friday, 11 November 2011

Phenotype Ontology search resources

I just spent a while looking for these so I thought I'd share my findings.

This is a list of website URI's associated with ontologies, mouse/mammalian phenotype ontology term ids specifically. Where I couldn't find a specific website that shows the details of the ontology, I used the EBI's general ontology lookup search.

For each of the term types, replace the %s with a full term id like MP:0010053. You can use the sprintf() function to do this :-).

MP:
http://www.informatics.jax.org/searches/Phat.cgi?id=%s
BSPO:
http://www.ebi.ac.uk/ontology-lookup/?termId=%s
CHEBI:
http://www.ebi.ac.uk/chebi/searchId.do?chebiId=%s
CL:
http://www.ebi.ac.uk/ontology-lookup/?termId=%s
ENVO:
http://www.ebi.ac.uk/ontology-lookup/?termId=%s
GO:
http://amigo.geneontology.org/cgi-bin/amigo/term_details?term=%s
IMR:
http://www.ebi.ac.uk/ontology-lookup/?termId=%s
MA:
http://www.informatics.jax.org/searches/AMA.cgi?id=%s
PATO:
http://www.ebi.ac.uk/ontology-lookup/?termId=%s

Friday, 4 November 2011

Quick JQuery expanding vertical menu

I'm just posting this as a reference for myself primarily, but if it helps anyone else then that's great. This is a super quick expanding vertical menu. You can animate it by passing 'slow' or 'fast' as an argument to the toggle() method.

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('.branch').click(function(){
        $(this).children('.subbranch').each(function(){
            return $(this).toggle();
        });
    });
});
</script>


<ul class='tree'>
<li class='branch'><a href='#'>Super Title 1</a>
<ul class='subbranch' style='display:none'>
    <li><a href="#">Item 1</a></li>
    <li><a href="#">Item 2</a></li>
    <li><a href="#">Item 3</a></li>
</ul></li>
<li class='branch'><a href='#'>Super Title 2</a>
<ul class='subbranch' style='display:none'>
    <li><a href="#">Item 4</a></li>
    <li><a href="#">Item 5</a></li>
    <li><a href="#">Item 6</a></li>
</ul></li>
</ul>

Thursday, 13 October 2011

New Largest Virus Discovered

The largest virus yet discovered has been isolated from ocean water pulled up off the coast of Chile.
Called Megavirus chilensis, it is 10 to 20 times wider than the average virus.
It just beats the previous record holder, Mimivirus, which was found in a water cooling tower in the UK in 1992.
Scientists tell the journal PNAS that Megavirus probably infects amoebas, single-celled organisms that are floating free in the sea.
The particle measures about 0.7 micrometres (thousandths of a millimetre) in diameter.
"It is bigger than some bacteria," explained Prof Jean-Michel Claverie, from Aix-Marseille University, Marseille, France.
"You don't need an electron microscope to see it; you can see it with an ordinary light microscope," he told BBC News.
Viruses cannot copy themselves; they need to invade a host cell if they want to replicate.
Like Mimivirus, Megavirus has hair-like structures, or fibrils, on the exterior of its shell, or capsid, that probably attract unsuspecting amoebas looking to prey on bacteria displaying similar features.
A study of the giant virus's DNA shows it to have more than a thousand genes, the biochemical instructions it uses to build the systems it requires to replicate once inside its host.
In the lab experiments conducted by Professor Claverie and colleagues, in which they infected fresh-water amoebas, Megavirus was seen to construct large trojan organelles - the "cells within cells" that would produce new viruses to infect other amoebas.
"Everything is initiated from a single particle, and then grows and grows to become this virion factory," explained Prof Claverie. "That's why it needs all these genes."
Megavirus was found off the coast of Las Cruces, central Chile. It was recovered as part of a general trawl in the ocean for biology of interest.
"This is a new way of doing virology," said Prof Claverie.
"Previously, we only discovered viruses because they caused disease in humans, or animals and plants. But now we are initiating what might be called environmental virology and we are looking for viruses everywhere.
"You just go to lakes, seas and oceans and pick up the water, and then you filter it, and try to rescue the virus by co-cultivating it with some potential host."
More generally, there is interest in ocean viruses because they have a major influence on populations of plankton, the microscopic organisms that form the base of many marine food chains. And when they kill plankton, viruses are also helping to regulate the planet's geochemical cycles as the dead organisms sink into the deep, locking away their carbon for aeons.

http://www.bbc.co.uk/news/science-environment-15242386

Friday, 26 August 2011

Copying radio button values to a group of radio buttons

My javascript is a little rusty and I've just spent a few hours trying to solve this problem: How do you copy the checked value of a radio button to a set/group of radio buttons?

I have this radio button group as the master group, the one that when I change what's checked I want it to modify the rest of the other set of radio buttons when a button was clicked:

<input type="radio" name="master" value="1"> Yes
<input type="radio" name="master" value="0"> No
<input type="radio" name="master" value=""> --
<input type="button" name="radiocopy" onclick="copydown()" value="Change All" ></button>

And the other groups are found in some rows of data and one of the columns requires a choice to be made: Yes, No, or missing.

<input type="radio" name="slaveRow1" value="1"> Yes
<input type="radio" name="slaveRow1" value="0"> No
<input type="radio" name="slaveRow1" value=""> --

<input type="radio" name="slaveRow2" value="1"> Yes
<input type="radio" name="slaveRow2" value="0"> No
<input type="radio" name="slaveRow2" value=""> --

<input type="radio" name="slaveRow3" value="1"> Yes
<input type="radio" name="slaveRow3" value="0"> No
<input type="radio" name="slaveRow3" value=""> --

Now what I wanted was that when I set the master to Yes, the rest of the radio buttons would change to Yes as well when I click the Change All button. Here's what I wrote:

function copydown(){
    var fm = document.forms["thenameofyourform"];

    //find out which master radio button is checked and assign value to masterValue
    var masterValue = null;
    for(i = 0; i < fm.elements['master'].length; i++){
        if(fm.elements['master'][i].checked == true)
            masterValue = fm.elements['master'][i].value;
    }

    //loop through all the form elements in the page
    for(i = 0; i < fm.elements.length; i++){
        //select only the radio buttons
        if( fm.elements[i].type == "radio" && fm.elements[i].name.indexOf("slaveRow") != -1){
            //check the value of each slave radio button and if it matches the
            //checked value of the master then check it
            if(fm.elements[i].value == masterValue)
                fm.elements[i].checked = true;
        }
    }
}

That seemed to do the trick. I must admit my Javascript is rusty. If you don't want to implement this with a button you can add a listener to the master radio buttons group.

Monday, 8 August 2011

Enums in PHP and Java

This is mainly for my personal reference. Enums are quite useful to use in projects and save typing and make sure Strings/Integers match, because it's not uncommon that, for example, you type "list" instead of the expected word "List" or misspell things and other such tirivial issues.

PHP:

<?php

//PHP has no native Enum type so you need to manipulate
//a normal class to work how you want it to
final class Season
{
    //class constants are inherantly public and static
    const SPRING = 'Spring';
    const SUMMER = 'Summer';
    const AUTUMN = 'Autumn';
    const WINTER = 'Winter';

    public function __toString()
    {
        //default return
        return self::SPRING;
    }
}

//Test the enum... prints out Spring.
echo ( new Season() );
//And if I wanted to choose just Summer
echo Season::SUMMER;


Java:

public enum Season {
    //define the values
    SPRING, SUMMER, AUTUMN, WINTER;
   
    //for extra useability have it return a string of the chosen enum when needed
    @Override
    public String toString(){
        switch(this){
            case SPRING: return "Spring";
            case SUMMER: return "Summer";
            case AUTUMN: return "Autumn";
            case WINTER: return "Winter";
            default: return "Spring";
        }
    }
}

//usage - prints out Summer
System.out.println( Season.SUMMER );

Friday, 29 July 2011

String DB

RAS, RAF, MEK, MAPK... or something like that. That's what I remember as being the chain of gene activation to activate an oncogene leading to cancer (P53 getting its ass kicked) . No I can't remember the details but these activation/interactions form a tree of what gene up or downregulates the function of another and it's quite a complicated part of genetics and bioinformatics. But I found a website recently that I hadn't seen before and thought of sharing it because apart from getting a nice little description of what the gene does in different species, it has nice spider diagrams like this showing gene relationships:





http://string-db.org/
A search example, PAX6: http://string-db.org/newstring_cgi/show_network_section.pl?caller_identity=expasy_api&identifier=pax6
If you click continue at the bottom of that page you see the diagram.

Wednesday, 13 July 2011

Ladybird vs. Aphid.... vs. Spider?

I thought Ladybirds ate Aphids and kept their population down. But apparently that isn't the whole truth! Check this out:



I don't know about you but I really do wonder if this is at all true. The roles of both the spider and the Ladybird seem so passive. I reckon there's something missing in the equation.

http://www.bbc.co.uk/nature/life/Coccinella_septempunctata#p0039ryj

Tuesday, 5 July 2011

Belly button fluff - bacterial haven


The human navel should be designated as a bacterial nature reserve, it seems. The first round of DNA results from the Belly Button Biodiversity project are in, and the 95 samples that have so far been analysed have turned up a whopping total of more than 1400 bacterial strains. In 662 cases, the microbes could not even be classified to family, "which strongly suggests that they are new to science", says team leader Jiri Hulcr of North Carolina State University in Raleigh.

The project was conceived as a light-hearted exercise in science communication, but is making a serious contribution to the understanding of microbial diversity. Since New Scientist wrote about the initiative in April, samples of bacteria taken when volunteers swabbed their navels with Q-tips have had their "DNA barcodes" read by sequencing the gene for 16S ribosomal RNA, widely used in studies of bacterial evolutionary relationships.

My own sample was among 10 per cent of those in the first round in which reactions to amplify the DNA present failed - so the next installment of the comparison of my belly button biome with that of fellow science writer Carl Zimmer will have to wait for another day. Still, Zimmer has already been having some fun with his results, finding among other things that his belly button hosts Georgenia bacteria, previously found in Asian soils.

Results like this reflect our ignorance of microbial diversity, Hulcr suggests: the inhabitants of our navels seem weird because biologists haven't sampled sufficiently extensively to document the full diversity of microbial life in a variety of habitats. He likens reactions to the first round of belly button results to the astonishment of the first European explorers seeing African big game - which today seem commonplace. "Now you're expecting rhino and elephants," Hulcr says.

Also, identifying bacteria to species is difficult. Noah Fierer's team at the University of Colorado, Boulder, classified them into "operational taxonomic units" having 16S ribosomal RNA gene sequences that differed by 3 per cent or less. Apply this standard to mammals, Hulcr explains, and dogs and cats would be lumped together. It means that a "match" between a belly button strain and a species known from the deep ocean, for instance, may actually represent two microbes separated by several million years of divergent evolution.

Although the total number of strains recorded was large, the results so far indicate that a small group of about 40 species accounts for around 80 per cent of the bacterial populations of our belly buttons. "It is tempting to think of the abundant species as the good, core biome of bacteria and the rare ones as transients, struggling to take hold, sometimes at our expense," says Rob Dunn, author of The Wild Life of Our Bodies, and head of the lab in which Hulcr works.

Confirming that theory will require studies on a new scientific frontier: belly button ecology.

Source: http://www.newscientist.com/blogs/shortsharpscience/2011/06/peter-aldhous-san-francisco-bu.html
Also see: http://idle.slashdot.org/story/09/03/02/1742219/Science-Unlocks-The-Mystery-Of-Belly-Button-Lint