Importance of list comprehensions in Python

A beginner to python programming is usually taught to use for loops to do a lot things. The temptation  is to bust out a for loop whenever you need to modify a list or string object, but this quickly leads to complex “loops within loops” code architectures that are hard to read (by humans), even though they may work OK.

A simple example:

>>>test_list = [2,4,6,8]

>>>for x in test_list:

…     new_list.append(x  + 1)

>>>new_list

[3,5,7,9]

A better approach is to take advantage of Python’s built-in list comprehension expressions, with the form ‘x for x in y’.

Example:

>>>new_list = [x+2 for x in test_list]

>>>new_list

[4,6,8,10]

This can be expanded to include conditionals, for example:

>>>stripped_list = [line.strip() for line in line_list if line !=””]

You can also loop over multiple elements like this:

>>>seq1=’abc’

>>>seq2=(1,2,3)

>>>[(x,y) for x in seq1 for y in seq2]

[(‘a’,1),(‘a’,2),(‘a’,3),(‘b’,1),(‘b’,2)….(‘c’,3)]

Practical Fragments: Natural Products as Fragments

There’s an interesting post at Practical Fragments regarding how natural products have been assembled into a small fragment library for screening and lead selection.   Natural products appear to have some advantages over synthetic fragments, including their “3D-ness” and the fact that they were screened by evolution to be protein-binders.

Important to use deuterated buffers in small molecule NMR

One way to make your life massively easier if you are doing NMR of small molecules, especially at low concentrations (sub-1mM), is to simply work out what buffer you’d like to use and then order all of the components in deuterated form ahead of time.

For example, if you would like to study your molecule in a buffer like HEPES with 5% DMSO, you can order fully-deuterated HEPES and DMSO from companies like CIL and Sigma-ISOTEC.  Although expensive, the time it can save you at the spectrometer and the enhanced quality of the data are likely worthwhile tradeoffs.

You can also go a step further and prepare your buffers in 100% D2O, making water suppression vastly easier and improving the quality of your spectra. These steps work together in a synergistic manner to dramatically improve your data quality when acquiring on small molecules at low concentrations.

From inhibitors to activators: rethinking drug action

Most small molecule drugs are designed to inhibit their target protein from carrying out its cellular function.  Drug discovery typically focuses on disrupting biochemical systems in cells in order to induce apoptosis (cell death) or reduce the activity of an overactive pathway.

Interestingly, it is becoming apparent that there may be a novel way of looking at the problem.  Instead of trying to muck up a cell’s function, new therapeutic approaches may seek to enhance the functioning of healthy biochemical pathways or systems that are under-activated owing to genetic mutation.

One example comes from the search for effective small molecule drugs against Parkinson’s disease (PD).  Several studies have recently shown that malfunctioning lysosomes are involved in the progression of PD by failing to clear waste and allowing the accumulation of misfolded proteins.   The lysosomal function is reduced in PD patients owing to mutations in a protein critical for proper functioning called PARK9.

Researchers are now looking for molecules that can stimulate the lysosomal autophagy pathway by interacting with PARK9 or other proteins.  By increasing the abnormally lowered activity of the pathway, it is hoped that increased clearance of PD-related plaques may be achieved.

Interestingly, a compound from traditional Chinese medicine (TCM) has been found to be activating towards autophagic activity and is now in development in the biotech industry.

More information can be found here:

http://www.alzforum.org/new/detail.asp?id=3172

Using R to create a dotplot with jittered x values

If you need to create a plot where you have a several groups of data that you want to distribute along the ‘y’ axis, but bin into one of several categories in x then you can do the following:

1) create a .csv file with your data in columns (you can use headers)

2) import the .csv file into R with: TEST <- read.table(“yourfile.csv”, sep=’,’, header=TRUE)

3) do the dotplot: dotplot(values ~ ind, data=stack(TEST), jitter.x=TRUE)

The important point here is the use of the “stack” function.  This converts vectors into factors; it also lets you create the type of dotplot where the data is plotted along ‘y’ while having the same ‘x’ value.