Exemple #1
0
#!/usr/bin/env python
"""
snippet.py

Author: Tony Papenfuss
Date: Mon Jun 23 23:32:21 EST 2008

"""

import os, sys
from alchemy import *
from blast import BlastFile, HSP

tableName = 'Devil454'  # Devil454, Platy454, PlatySolexa
dsn = 'sqlite:///test.db'

metadata = MetaData()

# Create the table and define the mapping
h = HSP()
hsps_table = createTable(tableName, metadata, h.attributes, h.converters)
mapper(HSP, hsps_table)

# Start a session & initialize database
session = startSession(dsn, metadata)

for h in session.query(HSP).filter(HSP.subjectId == '3'):
    print dir(h)
    print h
Exemple #2
0
    tableName = 'Devil454_alt'
    iFilename = os.path.join(
        homeDir,
        'databases/devil/transcriptome/reads/blast_results/blastn_tumour_v_opossum2.txt'
    )
    n = 472244
elif case == 3:
    tableName = 'Platy454'
    iFilename = os.path.join(
        homeDir, 'databases/platypus/venom/454/blat_platy_venom_reads.txt')
    n = 208523

metadata = MetaData()

# Create the table and define the mapping
h = HSP()
hsps_table = createTable(tableName,
                         metadata,
                         h.attributes,
                         h.converters,
                         indexedAttributes=['subjectId', 'sStart', 'sEnd'])
mapper(HSP, hsps_table)

# Start a session & initialize database
session = createSession(dsn, metadata)

if case in [1, 2]:
    # Devil 454 reads
    for i, line in enumerate(open(iFilename)):
        tokens = line.strip().split('\t')
        h = HSP(tokens[0:-2])
Exemple #3
0
elif case==2:
    tableName = 'Devil454_alt'
    iFilename = os.path.join(homeDir, 
        'databases/devil/transcriptome/reads/blast_results/blastn_tumour_v_opossum2.txt')
    n = 472244
elif case==3:
    tableName = 'Platy454'
    iFilename = os.path.join(homeDir, 
        'databases/platypus/venom/454/blat_platy_venom_reads.txt')
    n = 208523


metadata = MetaData()

# Create the table and define the mapping
h = HSP()
hsps_table = createTable(tableName, metadata, h.attributes, h.converters, 
    indexedAttributes=['subjectId', 'sStart', 'sEnd'])
mapper(HSP, hsps_table)

# Start a session & initialize database
session = createSession(dsn, metadata)

if case in [1,2]:
    # Devil 454 reads
    for i,line in enumerate(open(iFilename)):
        tokens = line.strip().split('\t')
        h = HSP(tokens[0:-2])
        h.convertBlockToGenomeCoords()
        session.save(h)
        if (i % 5000)==0:
Exemple #4
0
"""

import os, sys
from alchemy import *
from blast import BlastFile, HSP


tableName = "Devil454"  # Devil454, Platy454, PlatySolexa
dsn = "sqlite:///test.db"


metadata = MetaData()

# Create the table and define the mapping
h = HSP()
hsps_table = createTable(tableName, metadata, h.attributes, h.converters)
mapper(HSP, hsps_table)

# Start a session & initialize database
session = startSession(dsn, metadata)


# Load data
filename = "/Users/papenfuss/databases/devil/transcriptome/reads/blast_results/blastn_tumour_v_opossum.txt"
for i, h in enumerate(BlastFile(filename)):
    h.convertBlockToGenomeCoords()
    session.save(h)
    if i == 10:
        break
session.commit()