Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Sunday, 12 January 2014

Last year, I was mostly listening to...

I am not entirely sure that I trust the following, as my MacBook hard drive died in the summer of 2013 and a Time Machine backup was overdue. As a result, I think I lost a month or so of play counts and the resulting list is a bit biased towards recent acquisitions. Nevertheless, for posterity (and anyone curious), here is what I was listening to most in 2013 (compiled using the same script as last year.

Top 20 Tracks (most plays) of 2013

# Name Artist Album Plays
1 When I Grow Up Matilda the Musical Original Cast Matilda the Musical (Original Cast Recording) 30
2 Buck Rogers Feeder Echo Park 17
3 Walk Foo Fighters Wasting Light 13
= See The World Gomez How We Operate 13
5 The Duel Anna Phoebe Embrace EP 12
= How Far We've Come Matchbox Twenty Exile On Mainstream 12
7 The Farewell Anna Phoebe Rise of the Warrior 11
= Seven Days In The Sun Feeder Echo Park 11
= The Smell of Rebellion Matilda the Musical Original Cast Matilda the Musical (Original Cast Recording) 11
= No More Heroes Slash Apocalyptic Love (Special Edition) 11
11 Gypsy Anna Phoebe Gypsy 10
= Route 149(A) Anna Phoebe Gypsy 10
= Bombay to Beirut Anna Phoebe Gypsy 10
= See Through Blue Beth Orton Sugaring Season 10
= Viva La Vida Coldplay Viva La Vida Or Death And All His Friends 10
= We Can't Rewind Feeder Echo Park 10
= Naughty Matilda the Musical Original Cast Matilda the Musical (Original Cast Recording) 10
= The Hammer Matilda the Musical Original Cast Matilda the Musical (Original Cast Recording) 10
= His Girl The Budos Band The Budos Band II 10


Top 10 Albums (plays per track) of 2013

# Album Album_Artist Plays/Track
1 Embrace EP Anna Phoebe 8.75
2 Matilda the Musical (Original Cast Recording) Matilda the Musical Original Cast 8.05882352941
3 Gypsy Anna Phoebe 7.66666666667
4 Rise of the Warrior Anna Phoebe 7.41666666667
5 Echo Park Feeder 7.16666666667
6 Fossils Aoife ODonovan 6.3
7 Uno Green Day 6.0
8 Dos Green Day 5.84615384615
9 The Budos Band III (Bonus Version) The Budos Band 5.25
10 Hail to the King Avenged Sevenfold 5.1


There’s a few old favourites in there, like Green Day and Avenged Sevenfold, plus some new discoveries. Feeder is somewhat a blast from the past although I never really got into them at the time and mainly knew of them from a couple of tracks on the Gran Turismo soundtrack. The stand-out new artist in the lists is Anna Phoebe, which can best be described as violin rock music!

Anna Phoebe is instrumental, as is The Budos Band, which is good for background when writing or coding at work - hence the surge in plays over recent weeks. Matilda the Musical is just awesome - a Tim Minchin triumph! We went to see it live in London before the big move Down Under and it was so good that I bought the album straight away and it was the favourite in the car for a while. Indeed, if wasn’t for the MacBook death, I’m sure it would have racked up a load more plays. More on that later, I think.

It’s interesting to see some of my all time favourites are still hitting the most played list, as they did last year: Walk (Foo Fighters), See The World (Gomez), How Far We’ve Come (Matchbox Twenty) and No More Heroes (Slash) are all listen-to-before-you-die tracks. (I suspect that they might be there again next year!)


Top 10 Artists (Most listened to) of 2013

# Artist Plays Tracks
1 Feeder 231 63
2 Green Day 222 103
3 Anna Phoebe 193 25
= Avenged Sevenfold 193 57
5 Vitamin String Quartet 142 57
6 Matilda the Musical Original Cast 137 17
7 Jack Johnson 95 33
8 Matchbox Twenty 93 26
9 Foo Fighters 76 60
10 Gomez 64 65

Monday, 10 June 2013

Python in a Nutshell - free PDF available!

If you are a Python programmer, you might be interested to know that you can get a free PDF of Python in a Nutshell, 2nd Edition from IT ebBooks. It's a few year's old now but still has a lot of useful basic Python syntax. It doesn't cover Python 3, so if you are a newbie you might want to hunt down some specific advice about programming Python 3 compatible code in Python 2.7. (To be honest, I still haven't plucked up the courage to look at the Python 2 vs. Python 3 difference myself but it might be worth having a go at the Python 3 tutorial.)

Saturday, 8 June 2013

Marvellous Markdown

Another positive outcome of the recent Software Carpentry boot camp was the excuse and opportunity to get a bit more to grips with Markdown. This is really useful pseudocode that retains a high degree of human readability in plain text form, whilst being easily converted to HTML and other rich text formats. I'd already used it a bit for some of my content on the University of Southampton Computational Modelling Group website but I'd never fully realised its flexibility, value and potential until I started writing README files in it.

I won't try to explain Markdown itself here. The Wikipedia article is pretty informative if you want to know more. Instead, this a quick post to highlight/bookmark some useful Markdown tools that I've come across.

Markable

The first is the Markable website.
Markable top
This is great if you just want to try your hand at a bit of Markdown and see what the HTML conversion would look like. Simply type your text in the online Markable editor and the HTML window will automatically update to reflect the changes! You can then copy the Markdown to the clipboard or export Markdown/HTML to a file.
Markable bottom
If you see yourself using Markdown a lot, as I now do, you can register and take advantage of a whole bunch of other tools, such as (auto)saving content to work on later or exporting the Markdown (or HTML) directly into Dropbox.
Markable screenshot of Python Markdown info

Markdown Service Tools

Of course, if you are like me then saving to HTML code might not be enough for you. You might want to see the HTML code and/or copy it for use elsewhere. (I write all my blog posts in the HTML editor, for example.) On a Mac there is the tremendously useful Markdown Service Tools by Brett Terpstra that, among other things, includes tools for precisely this. Simply download the zip file, unpack and then copy the relevant *.workflow files to your OS X System Service folder:
~/Library/Services/
(Brett has a description of how to install Services here. You might have to make the Services/ folder first - I did.) This makes those services available via the Services menu item (or right-click → Services) across a range of Apple applications. My favourite so far is the "md - Convert - HTML to Clipboard" service, which converts highlighted Markdown text to HTML and copies it directly onto the clipboard. In combination with the Markable editor, I think this could be really useful.

Python-Markdown

It's worth quickly mentioning that there's a Markdown Python library, if for no other reason than that is appears in the Markable screen grab above! This can be used for easy conversions between formats, which might be handy for coding up batch conversions of *.md to HTML README files etc. I really need to save this one for another day as I am still getting to grips with it and working out how/where it can be useful for me.

Tuesday, 1 January 2013

My Top Tunes of 2012

Every now and then, I like to exercise my geekiness by writing a program to do something trivially unimportant just for the fun of it. One such exercise is a little Python program for processing iTunes playlist exports. It's still in early development (and doesn't handle accented text properly) but it's good for calculating crude summary stats for Albums/Artists and differences between exports at different times. I therefore thought that I'd compare my iTunes library as of 27/12/12 with an export almost exactly a year ago (20/12/11).

The New Year period is always full of "best of" lists, so here are the resulting "Best of 2012" lists for my iTunes library.

Top 20 Tracks (Most plays) of 2012

#NameArtistAlbumPlays
1WalkFoo FightersWasting Light28
2The English WayFightstarBe Human (Deluxe Edition)27
=ZihautanejoFightstarOne Day Son This Will All Be Yours27
4No More HeroesSlashApocalyptic Love (Special Edition)26
=One Day SonFightstarOne Day Son This Will All Be Yours26
6FloodsFightstarOne Day Son This Will All Be Yours25
7CheersThe WildheartsCoupled With24
8Our Last Common AncestorFightstarOne Day Son This Will All Be Yours22
9Apocalyptic LoveSlashApocalyptic Love (Special Edition)21
=Standing in the SunSlashApocalyptic Love (Special Edition)21
=We Apologise For NothingFightstarOne Day Son This Will All Be Yours21
12Mvua NyeusiFightstarBe Human (Deluxe Edition)20
=Amaze UsFightstarOne Day Son This Will All Be Yours20
14Youre a LieSlashApocalyptic Love (Special Edition)19
15Dark Star (Acoustic Version)HypnogajaDark Star - EP18
16One Last ThrillSlashApocalyptic Love (Special Edition)17
=Thank You God (Live)Tim MinchinTim Minchin and the Heritage Orchestra (Live)17
18AnastasiaSlashApocalyptic Love (Special Edition)16
=Mazel Tov CocktailThe WildheartsChutzpah16
=Hazy EyesFightstarGrand Unification16
=Wake UpFightstarGrand Unification16
=See The WorldGomezHow We Operate16
=Floods [Instrumental]FightstarOne Day Son This Will All Be Yours16
=The Fence (Live)Tim MinchinTim Minchin and the Heritage Orchestra (Live)16
=Down Down DownCharlie SimpsonYoung Pilgrim16

The list is dominated by Fightstar tracks, which is perhaps not surprising because I discovered them around the time of the first export in December 2011. A few Avenged Sevenfold tracks almost made it but largely missed out due to only being added in the last couple of months, although (along with many of these) they feature in the Top Albums (below).

I obviously recommend all of these tracks but I think that three deserve a special mention. See The World by Gomez is not just in my Top 20 plays for 2012, it's my most played track of all time. This is partly because my wife also loves it (it was our leaving music at our wedding) but mostly because it's just a damn fine track. Walk by Foo Fighters is quite possible the perfect track in my book. I just cannot think of any way to make it better. I love it! The final track with a special mention is Floods by Fightstar, which not only appeared in the top 10 but the Instrumental version also appeared in the Top 20. (Combined, they would be the Number 1 song of 2012.)

Top 10 Albums (Plays per Track) of 2012

#AlbumArtistPlays/Track
1Apocalyptic Love (Special Edition)Slash15.7
2NightmareAvenged Sevenfold12.3
3Grand UnificationFightstar10.9
4Dark Star - EPHypnogaja10.7
5One Day Son This Will All Be YoursFightstar9.2
6Cast Of ThousandsElbow8.8
7Be Human (Deluxe Edition)Fightstar8.7
8Avenged SevenfoldAvenged Sevenfold8.1
9Waken The FallenAvenged Sevenfold7.7
10Giftes 1 & 2Antlered Man7.4

For anyone who's read my previous music posts, the rock-heavy nature of this list will come as no surprise. Somewhat reassuringly, quite a few of them have featured in posts (linked from the Artists, below - the Album names link to Amazon in case you want a listen). Hypnogaja and Antlered Man are lined up for posts in 2013.
I actually discovered Hypnogaja when looking for Apocalyptic Love by Slash as they have a track called Apocalyptic Love Song. That's not on the six-track Dark Star EP but it was my access point to quite an extensive catalogue on emusic. (I'm not sure if an EP counts as an album but six tracks seemed like enough to warrant inclusion.)

Top 10 Artists (Most listened to) of 2012

#ArtistPlaysTracks
1Fightstar52055
2Avenged Sevenfold32947
3Hypnogaja28543
4Slash27543
5Elbow23936
6The Wildhearts17777
7Muse16296
8God Is an Astronaut14240
9Tim Minchin12833
10Foo Fighters11761

Again, many of these have featured in previous posts (linked in the table) and the rest are definitely deserving of them. I guess that God is an Astronaut - another emusic discovery - deserves a special mention here as the only Artist not to feature a top song or album. They just have a very solid and appealing catalogue across the board.

Muse also stand out a bit as I have almost 100 tracks by them. Crazy! I knew I was a fan but did not realise I had quite so many. (Most of them are quite old, which is why they are not higher up the charts, I fancy.) They're not top overall in this respect, though: The Red Hot Chili Peppers (159 tracks) and Blur (113) both beat them. Green Day (80) comes in fourth and probably should have featured, except that I have been holding off getting ¡UNO!, ¡DOS! and ¡TRÉ! in case I got them from Christmas. (I didn't.) Lots to look forward to in 2013!

Friday, 14 September 2012

University of Southampton builds world's first Raspberry Pi supercomputer

It's a bit of a busy time of year, so blogging is on the back burner for a bit (and I'm accumulating half-written posts for later!) but this was just so weird and fun that I had to write a quick post. If you haven't heard of a raspberry pi computer before, you can find out all about them here. Basically, they are a very small, very cheap ($25) "credit-card sized computer that plugs into your TV and a keyboard".



According to the FAQ:
It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming.
Well, Prof Simon Cox (and colleagues) of the University of Southampton decided to go one better and used a bunch of them to teach his kid how to build a supercomputer! You can read about it on the Computational Modelling Group website.



What can it do? Well, according to Prof Cox:
“The first test we ran – well obviously we calculated Pi on the Raspberry Pi using MPI, which is a well-known first test for any new supercomputer.”
I suspect it can do a bit more than that: the 64 processor system has 1Tb of memory! Not bad for £2500 (plus switches and, possibly, lego).

Wednesday, 4 July 2012

The Glossariser 1.0 is here

A while ago, I made a molecular evolution glossary page in case it was of use to anyone. Being a geek and a programmer, rather than actually making the webpage myself, I made a program to make the webpage for me. From a plain text set of terms and definitions, this program will construct a formatted web page, including hyperlinks between terms (if so desired).

As I now need to make another glossary for MapTime, I thought I would throw together a quick cgi script to make the code available online, and the Glossariser was born.



It's rather crude at present and, in particular, contains no documentation - trial and error only, I'm afraid! Input is, again, raw text with a number of delimiter options. (It only splits on the first occurrence of the chosen delimiter, so periods can be used quite happily.) There are currently a limited selection of output styles available. Unless "tabs" is chosen, terms will be split up according to their first letter and output alphabetically:



The "Header" or "bold" style refers to the formatting for the letters A-Z. The "table" output is similar but has each letter in a row of a table. The tabs style was a bit experimental and doesn't really work that well, so I won't bother to explain it here. (Feel free to try it!)

If you just want a standalone HTML page, you can (hopefully) just save the output directly. Otherwise, you will either want to copy and paste the text into a Word document or, to use in Blogger or other existing framework, just "view source" and copy the bits you need. (That's how I made the molecular evolution glossary.)

I have some plans for improvements - there are a few bugs to iron out and I would like to add URLs etc. - but, as with most things, they will probably wait until I, or someone else, really wants them in place. So, if it is useful but doesn't quite do what you want, let me know and I might be able to update it. There's also no reason that its use should be limited to a glossary. Any list of names/keywords and associated short paragraphs will do - perhaps I should make the alphabetical arrangement optional in this case?

The Glossariser is available at: http://bioware.soton.ac.uk/glossariser.html.

(If it ever saves you an evening of writing HTML and you want to say thanks, buy The Cabbages of Doom for just 99p! ☺ (You can't blame a guy for trying!))

Sunday, 29 April 2012

SeqSuite: another blog is born

Although this is my blog, I feel a bit funny about explicitly blogging about work stuff in a blatant "look at what I've done, please read/use/cite it!" fashion. I have therefore created a new blog explicitly for that side of things. Actually, it has existed for a while but not really had much content until today's post about SLiMMaker (my second solo excursion into python CGI). The blog is currently titled SeqSuite: open-source bioinformatics in Python and the central theme is the application and development of the various tools that I have cobbled together over the years, although I hope to diversify into other related stuff should time allow.

The main focus is actually SLiMSuite, which is the collection of short linear motif (SLiM) tools that I have been involved in developing. (The term "SLiM" will probably be my longest lasting contribution to science. It's weird seeing it start to appear in textbooks! (Although I must point out that I did not invent the concept. I'll save SLiMs for another post, I think.)) SLiMSuite is both the main pillar of my research but also, I think, the more original and unique of my software. (Some of the other stuff I have made because I have been too lazy to hunt down something that does what I want.)

Despite the ascendancy of SLiMSuite, I've stuck with "SeqSuite" as the name, though, as (a) other "Slim Suites" seem to exist and I want to head off any legal objections in advance, and (b) I have some other tools that are nothing to do with SLiMs and, along with SLiMSuite, form the larger SeqSuite package.

I'm still not entirely sure how the two blogs will work - finding the time to write one blog is hard enough - but I think I will continue to post the more "human" aspect of work-related matters here, and the more technical aspects on the SeqSuite blog. (Hopefully, I can convince some of my collaborators to contribute there too.) I think, like a lot of academics, I realise the importance of trying to communicate what we do, but haven't quite worked out yet the best way to go about it.

Tuesday, 24 April 2012

CGI, where've you bin all my life?

I'd been meaning to play around with CGI (Common Gateway Interface) programming for some time as a way of making simple functional websites. I finally got round to it last month, thanks to a great introductory page at Tutorials Point. What I did not realise is quite how easy it was.

I've still only really scratched the surface and scanned over the page to get something up quickly but, in essence, you only need three things:
1. A webserver that supports CGI.

2. An html page containing some "form" code that contains a submit button and (optionally) some input options (e.g. text boxes or checkboxes).

3. A python script (or another language) that generates HTML code based on the variables and values from the form.
And that's essentially it. Actually, you don't even need (2), as you can feed variables directly to the cgi script, but it makes it easier for the user, I think.

My first attempt at this can be found here. It's a bit of silly fun but it shows what can be done with just a few simple lines of code. I've cheated a little bit by using an existing python module to generate the middle of the HTML code but, in a way, that's the point - you can easily adapt existing functional code to output text.

In this case, I use the random "Zen wisdom" text strings that are generated in my code to lighten up error messages when I'm debugging. (If you ever use one of my programs, you sometimes come across such an error message, which always causes confusion (and usually embarrassment for me!) but I think it's a small price to pay for making debugging more fun!) The scary thing is how often the random Zen Wisdoms sound deep and meaningful, e.g.
"It is bold to play jenga with blocks of passion."
Well, maybe not that deep and meaningful!

Friday, 16 March 2012

Python ValueError: bad marshal data

I have been programming for many years but consider myself to be somewhat of an "empirical programmer", i.e. I am almost entirely self-taught. As a result, I sometimes come across new and exciting error messages that I have neither encountered nor understand. I have just had one such error:
ValueError: bad marshal data
This was associated with an import command for several modules.

I still don't know what bad marshal data is (it sounds like it should be something to do with Wild West movies) but, fortunately, I have found an easy fix: just delete all the compiled *.pyc files. Missing ones are remade when you run your python code anyway. Problem solved without any need to delve into the murky underworld of bad marshals.