This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an auto-generated Django model module. | |
# You'll have to do the following manually to clean this up: | |
# * Rearrange models' order | |
# * Make sure each model has one field with primary_key=True | |
# Feel free to rename the models, but don't rename db_table values or field names. | |
# | |
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]' | |
# into your database. | |
# | |
# I made the following changes to the models generated using inspectdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Daniel E. Cook 2013 | |
(danielecook.com) | |
This script takes a csv containing authors and associated Pubmed identifiers (PMIDs) of their publications and outputs a formatted html document of their publications. | |
The first row of the csv should contain the authors, and each row below their publications (as PMIDs). If you put something other than a PMID in it will simply be outputted - | |
so you can add publications that might not be in pubmed or that you want to display in a certain way. | |
This script might be useful for individuals who maintains publication lists for researchers at a university, for instance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint as pp | |
from Bio import Entrez | |
Entrez.email = "[email protected]" | |
def pull_line(var_set,line): | |
""" | |
This function parses data from lines in one of three ways: | |
1.) Pulls variables out of a particular line when defined as "variablename=[value]" - uses a string to find the variable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Downloading pub tables. Requires wget. Can be installed using home brew for mac | |
# More information is available here: http://brew.sh/ | |
mkdir ../data/ | |
# Download Files | |
wget --timestamping --directory-prefix='../data/' 'http://hgdownload.cse.ucsc.edu/goldenPath/hgFixed/database/pubsArticle.txt.gz' | |
wget --timestamping --directory-prefix='../data/' 'http://hgdownload.cse.ucsc.edu/goldenPath/hgFixed/database/pubsMarkerAnnot.txt.gz' | |
## wget --timestamping --directory-prefix='../data/' 'http://hgdownload.cse.ucsc.edu/goldenPath/hgFixed/database/pubsSequenceAnnot.txt.gz' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env | |
# Requires wget - can be installed using homebrew if you are on a mac. | |
## Installation Variables ## | |
CHADO_DB_USERNAME="" | |
CHADO_DB_PASS="" | |
CHADO_DB_NAME="chado" | |
PATH_TO_PSQL="/Applications/Postgres.app/Contents/MacOS/bin/psql" # I use a special application for mac, for convenience. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: Requires mysqldb; install using: | |
# pip install MySQL-python | |
from MySQLdb.constants import FIELD_TYPE | |
import _mysql | |
db = None | |
def fetch_gene_coordinates(gene_name,build): | |
global db # db is global to prevent reconnecting. | |
if db is None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extract all worksheets form an excel file and export as individual CSVs | |
# Install xlrd with 'pip install xlrd' | |
# Thanks to Boud from http://stackoverflow.com/questions/10802417/how-to-save-an-excel-worksheet-as-csv-from-python-unix | |
import xlrd | |
import csv | |
# Open the workbook | |
x = xlrd.open_workbook('excel_file.xlsx') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlrd # pip install xlrd | |
import csv | |
import os | |
def export_workbook(filename): | |
# Open workbook for initial extraction | |
workbook = xlrd.open_workbook(filename) | |
filename = os.path.splitext(filename)[0] # Remove extension | |
if not os.path.exists(filename): | |
os.makedirs(filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download KEGG Data (Pathways) | |
#==============================# | |
# Download select files from UCSC (hg19) | |
for var in keggPathway KeggMapDesc knownGene kgXref | |
do | |
wget --timestamping --directory-prefix test 'ftp://hgdownload.cse.ucsc.edu/goldenPath/hg19/database/$var.txt.gz' | |
gunzip kegg/$var.txt.gz | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/Python | |
import sqlite3 | |
import os | |
import glob | |
import time | |
import sqlalchemy | |
from sqlalchemy import Table, Column, Index, Integer, String, Float, MetaData, ForeignKey | |
from sqlalchemy import create_engine | |
import datetime |
OlderNewer