Ejemplo n.º 1
0
        

    def __add(self, record):
        "Add a single record to libinfo table"

        self.__inform("\tadding record ID %s\n" % record['ID'], 2)

        self.__cursor.execute('''INSERT INTO %s (%s) VALUES (%s);''' \
                              % ( self.tablename,                    \
                                  ','.join(record.keys()),           \
                                  ','.join([(isinstance(val, str) and '"%s"' % val or '%i' % val) for val in record.values()]) )
                              )


    def __inform(self, txt, level=0):
        "output progress information to stderr if in 'verbose' mode"

        if self.verbose and level <= self.verbose:
            self.log.write(txt)


if __name__ == "__main__":
    import load_libinfo, configuration
    conf   = configuration.Configuration(filename='configuration_hsa_chr21_pseudoknot.txt')
    loader = load_libinfo.load_libinfo(libinfoFile='%s/Hs_LibData.dat' % conf['hsa']['MetaDataStoragePath'], conf=conf, verbose=1)
    print >> sys.stdout, load_libinfo.__doc__
    print >> sys.stdout
    print >> sys.stdout, "Load library info as specified in %s (y/n)?" % loader.conf.configFile()
    if(sys.stdin.readline().startswith("y")):
        loader.parse_and_load_file()
    sys.stderr.write('--- %s : finished downloading rawdata (WARNING: there were errors)\n' % datetime.datetime.now())


# 2. load rawdata into MySQL
############################################################
log.write('### %s : loading rawdata/metadata into MySQL\n' % datetime.datetime.now())
sys.stderr.write('### %s : loading rawdata/metadata into MySQL\n' % datetime.datetime.now())

# if existing, parse and load special libinfo data
libinfoFile = None
if species == 'hsa' and os.path.exists('%s/Hs_LibData.dat' % conf['hsa']['MetaDataStoragePath']):
    libinfoFile = '%s/Hs_LibData.dat' % conf['hsa']['MetaDataStoragePath']
if species == 'mmu' and os.path.exists('%s/Mm_LibData.dat' % conf['mmu']['MetaDataStoragePath']):
    libinfoFile = '%s/Mm_LibData.dat' % conf['mmu']['MetaDataStoragePath']
if not libinfoFile is None:
    loader = load_libinfo.load_libinfo(libinfoFile=libinfoFile, conf=conf, verbose=1, log=log)
    loader.parse_and_load_file()

# now load all standard tables that were just downloaded
# importer = MakeMySQL.MakeMySQL(conf=conf, log=log)
###!!!have to add keys to hg19 because UCSC doesn't provide individual chrom spliced est data
sys.stderr.write('\nAll Tablenames to be imported:\n %s\n\n' % slurp.tablenames)

#add the chromosome intron data
extraTableNames = []
#slurp.tablenames[species]['knownGene'] = '/home/chris/Desktop/SG/taeGut1/RawData/'
slurp.tablenames[species]['knownGene'] = '/home/chris/Desktop/SG/mm9/RawData/'
for chrom in chromosomes:
	tn = '%s_intronEst' % chrom
	slurp.tablenames[species][tn] = slurp.tablenames[species]['knownGene'] #same directory
Ejemplo n.º 3
0
log.write('### %s : loading rawdata/metadata into MySQL\n' %
          datetime.datetime.now())
sys.stderr.write('### %s : loading rawdata/metadata into MySQL\n' %
                 datetime.datetime.now())

# if existing, parse and load special libinfo data
libinfoFile = None
if species == 'hsa' and os.path.exists(
        '%s/Hs_LibData.dat' % conf['hsa']['MetaDataStoragePath']):
    libinfoFile = '%s/Hs_LibData.dat' % conf['hsa']['MetaDataStoragePath']
if species == 'mmu' and os.path.exists(
        '%s/Mm_LibData.dat' % conf['mmu']['MetaDataStoragePath']):
    libinfoFile = '%s/Mm_LibData.dat' % conf['mmu']['MetaDataStoragePath']
if not libinfoFile is None:
    loader = load_libinfo.load_libinfo(libinfoFile=libinfoFile,
                                       conf=conf,
                                       verbose=1,
                                       log=log)
    loader.parse_and_load_file()

# now load all standard tables that were just downloaded
# importer = MakeMySQL.MakeMySQL(conf=conf, log=log)
###!!!have to add keys to hg19 because UCSC doesn't provide individual chrom spliced est data
sys.stderr.write('\nAll Tablenames to be imported:\n %s\n\n' %
                 slurp.tablenames)

#add the chromosome intron data
extraTableNames = []
#slurp.tablenames[species]['knownGene'] = '/home/chris/Desktop/SG/taeGut1/RawData/'
slurp.tablenames[species]['knownGene'] = '/home/chris/Desktop/SG/mm9/RawData/'
for chrom in chromosomes:
    tn = '%s_intronEst' % chrom