Posts

Showing posts from February, 2008

Simple python script to list files in a directory.

print files names in a directory... easy but useful. import os dir = os.getcwd() f = open( "_list.txt" , "w" ) count = 0 for item in os.listdir(dir):         print item + "\n",         f.writelines( item + "\n" ),         count = count+1 f.writelines( "the number of documents is %d" % count ), print "the number of documents is %d" % count , f.close()

Python and Biotext mining

I've been working with python a lot lately for getting documents and I've written python utility programs to make some of my daily tasks easier for extracting data from pubmed. I was using the packages from Biopython to query the pubmed server, but to be honest, it was taking way too long to return results so I created my own and it's fast enough to retrieve # for each pumbed id get the elemets from the xml for oid in ls:     try :         dom = minidom.parse(urllib.urlopen("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id="+oid+"&retmode=xml"))         pmid = dom.getElementsByTagName("PMID")[0].childNodes[0].data         journalname = dom.getElementsByTagName("MedlineTA")[0].childNodes[0].data         authorname = dom.getElementsByTagName("AuthorList")[0].getEleme...