Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    Archive for the 'Notepad' Category

    Short miscellaneous notes

    My favourite command line for mirroring with wget

    9th January 2011

    wget ––continue ––mirror ––page-requisites ––adjust-extension ––convert-links ––backup-converted ––limit-rate=500k ––wait=2 URL

    (short form: wget -cmpEkK ––limit-rate=500k -w 2 URL)
    Read the rest of this entry »

    Posted in *nix, Notepad | No Comments »

    How to relay outgoing postfix emails via another mail server (e.g. your ISP)

    4th December 2010

    Here’s a simple and clear guide for gmail, which also definitely works with other relay hosts. I’ve used it to configure my ISP’s mail relay (they block outgoing port 25) on a Debian Squeeze laptop.

    Posted in *nix, how-to, Links, Notepad, Software | No Comments »

    How to replace newlines with commas, tabs etc (merge lines)

    16th November 2010

    Imagine you need to get a few lines from a group of files with missing identifier mappings. I have a bunch of files with content similar to this one:

    ENSRNOG00000018677 1368832_at 25233
    ENSRNOG00000002079 1369102_at 25272
    ENSRNOG00000043451 25353
    ENSRNOG00000001527 1388013_at 25408
    ENSRNOG00000007390 1389538_at 25493

    In the example above I need '25353', which does not have corresponding affy_probeset_id in the 2nd column.

    It is clear how to do that:

    CODE:
    1. sort -u *_affy_ensembl.txt | grep -v '_at' | awk '{print $2}'

    This outputs a column of required IDs (EntrezGene in this example):

    116720
    679845
    309295
    364867
    298220
    298221
    25353

    However, I need these IDs as a comma-separated list, not as newline-separated list.

    There are several ways to achieve the desired result (only the last pipe commands differ):

    CODE:
    1. sort -u *_affy_ensembl.txt | grep -v '_at' | awk '{print $2}' | gawk '$1=$1' ORS=', '

    CODE:
    1. sort -u *_affy_ensembl.txt | grep -v '_at' | awk '{print $2}' | tr '\n' ','

    CODE:
    1. sort -u *_affy_ensembl.txt | grep -v '_at' | awk '{print $2}' | sed ':a;N;$!ba;s/\n/, /g'

    CODE:
    1. sort -u *_affy_ensembl.txt | grep -v '_at' | awk '{print $2}' | sed ':q;N;s/\n/, /g;t q'

    CODE:
    1. sort -u *_affy_ensembl.txt | grep -v '_at' | awk '{print $2}' | paste -s -d ","

    These solutions differ in efficiency and (slightly) in output. sed will read all the input into its buffer to replace newlines with other separators, so it might not be best for large files. tr might be the most efficient, but I haven't tested that. paste will re-use delimiters, so you cannot really get comma-space ", " separation with it.

    Sources: linuxquestions 1 (explains used sed commands), linuxquestions 2, nixcraft.

    Posted in *nix, Bioinformatics, how-to, Notepad, Software | No Comments »

    Batch-retrieve EntrezGene homologs using NCBI’s HomoloGene and R’s annotationTools

    27th October 2010

    1. Install the annotationTools R package:
      source("http://bioconductor.org/biocLite.R")
      biocLite("annotationTools")
    2. Download full HomoloGene data file from ftp://ftp.ncbi.nlm.nih.gov/pub/HomoloGene/current
    3. library(annotationTools)
    4. homologene = read.delim("homologene.data", header=FALSE)
    5. mygenes = read.table("file with one entrez ID of the source organism per line.txt")
    6. getHOMOLOG(unlist(mygenes), taxonomy_ID_of_target_organism, homologene) [alternatively, wrap the call to getHOMOLOG into unlist to get a vector]

    It might be easier to achieve the same results with a Perl script calling NCBI's e-utils.

    Posted in Bioinformatics, how-to, Notepad | 1 Comment »

    The world’s shortest marketing plan (4P cheat sheet)

    24th October 2010

    Source: Kelly's think tank.

    Posted in Links, Notepad, Startups | No Comments »

    Workplace or gamer’s HQ? ;)

    16th October 2010

    Find out more about the depicted office. That would be a nice setup for flight and/or space simulators, I guess.

    TinEye Firefox extension helped finding more nice workplaces.

    And Stefan in his office description provided some more links to multi-display workplaces - Mitch Haile's and Kevin Connollie's among others.

    Posted in Links, Misc, Notepad | No Comments »

    Simple and efficient Drupal upgrades: patch!

    3rd January 2010

    Just a quick note: upgrading Drupal using a patch file is a really efficient and fast method, especially because diff/patch files are available for different Drupal version combinations.

    Posted in Drupal, Links, Notepad, Web | No Comments »