Monday, June 21, 2010

Tweeted from R

Today, I tweeted from R. HML.

library(twitteR)
tweet("R one-liner", session=initSession("username","password"))
http://twitter.com/kzfm/status/16724542437

Friday, May 07, 2010

QRSMILES

Today, I realized that QR-code is very easy to deal with SMILES string. HML.

import qrencode
qrencode.encode_scaled("CN(CCOC1=CC=C(C=C1)CC2C(=O)NC(=O)S2)C3=CC=CC=N3",100) [2].save("rosiglitazone.png")
 rosiglitazone

Thursday, April 15, 2010

Make bib file from Pubmed-ID

Today, I wrote a code of making bib-file from pubmed in Python. HML.


def pm2bib(pm):
    author = "; ".join(pm['AU'])
    year = pm['DP'][0:4]
    bib = """@article{PMID:%s,
author = {%s},
title = {%s},
journal = {%s},
year = {%s},
volume = {%s},
number = {%s},
pages = {%s},
}
""" % (pm['PMID'],author,pm['TI'],pm['TA'],year,pm['VI'],pm.get('IP',""),pm['PG'])
    return bib

if __name__ == "__main__":

    from Bio import Entrez, Medline

    Entrez.email = "xxx@gmail.com"
    record = Entrez.read(Entrez.esearch(db="pubmed",term="biopython"))
    idlist = record["IdList"]
    records = Medline.parse(Entrez.efetch(db="pubmed",id=idlist,rettype="medline",retmode="text"))

    for record in records:
        print pm2bib(record)

Sunday, March 28, 2010

chemoinformaics in Scala

Today, I wrote a testcode in Scala. HML

import com.metamolecular.mx.calc.MassCalculator
import com.metamolecular.mx.io.daylight.SMILESReader

object MxTest {
  def main(args: Array[String]) {
    val calc = new MassCalculator
    for (mol <- args) {
      val mw = calc.findAveragedMass(SMILESReader.read(mol))
      println(mol + ": " + mw)
    }
  }
}

Thursday, March 25, 2010

LU-decomposition

Today, I decomposed a matrix into an LU-decomposition in R. HML

library(Matrix)
x <- Matrix(rnorm(9), 3, 3)
elu <- expand(lu(x,sparse=F))
y <- elu$L %*% elu$U