@posttask( touch_file("ucsc_encode.import") )
@files( PARAMS["filename_ucsc_encode"], "ucsc_encode.import") 
def importUCSCEncodeTracks( infile, outfile ):
    
    statement = '''
    mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -B -e "SELECT * FROM %(tablename)s" %(ucsc_database)s |\
   python %(scriptsdir)s/csv2db.py %(csv2db_options)s \
              --table=%(tablename)s \
    >> %(outfile)s

    '''

    dbhandle = sqlite3.connect( PARAMS["database"] )

    cc = dbhandle.cursor()
    tables = set( [ x[0] for x in cc.execute( "SELECT name FROM sqlite_master WHERE type='table'") ] )
    cc.close()
    
    for tablename in getUCSCTracks( infile ):
        if tablename in tables:
            E.info( "skipping %(tablename)s - already exists" % locals())
            continue            
            
        E.info( "importing %(tablename)s" % locals() )
        P.run()

############################################################
############################################################
############################################################
## import UCSC encode tracks
############################################################
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_vitaminD.py/importUCSCEncodeTracks/original