예제 #1
0
def reinstallGenomes(genomeList, username, genomeListIsFn='True', verbose='False'):
    "genomeList username genomeListIsFn=True verbose=False"
    from quick.application.GalaxyInterface import GalaxyInterface
    from gold.util.CustomExceptions import PreprocessError
    from quick.extra.StandardizeTrackFiles import PlainMover
    from config.Config import DebugConfig

    genomeListIsFn = ast.literal_eval(genomeListIsFn)
    verbose = ast.literal_eval(verbose)

    prevPassOnPreprocessExceptions = DebugConfig.PASS_ON_PREPROCESS_EXCEPTIONS
    prevVerbose = DebugConfig.VERBOSE
    DebugConfig.PASS_ON_PREPROCESS_EXCEPTIONS = True
    DebugConfig.VERBOSE = verbose

    track_cats = ['Sequence:DNA', 'Genome build properties', 'Genes and gene subsets', 'Sample data']

    if genomeListIsFn:
        genomes = [_.strip() for _ in open(genomeList)]
    else:
        genomes = genomeList.split(',')

    for genome in genomes:
        genome = genome.strip()
        print genome

        if GenomeInfo(genome).installed and GenomeInfo._queryShelveWithKey(genome, 'r', old=False) is not None:
            # Trigger installation double-check
            gi = GenomeInfo(genome)
            gi.installed = False
            gi.store()
            if gi.isInstalled():
                print '\n**Genome "{}" was alread installed in the new shelve. Skipping!**\n'.format(genome)
                continue

        for track_cat in track_cats:
            try:
                GalaxyInterface.startPreProcessing(genome, track_cat.split(':'), username)
            except PreprocessError, e:
                traceback.print_exc()
                print

                match = re.search(r'trackName="([^"]+)"', str(e))
                if match:
                    trackName = match.group(1).split(':')
                    PlainMover.parseFiles(genome, trackName, 'std_to_error')
                    print '\n\n**Moved track "{}" to "parsingErrorTracks" file structure**\n'.format(':'.join(trackName))

        genome_info = GenomeInfo(genome)
        installed = genome_info.flagAsInstalled(username)
        if installed:
            print '\n**Genome "{}" was reinstalled successfully!**\n'.format(genome)
        else:
            print '\n**Genome "{}" was not reinstalled!**\n'.format(genome)
    def execute(cls, choices, galaxyFn=None, username=''):
        '''Is called when execute-button is pushed by web-user.
        Should print output as HTML to standard out, which will be directed to a results page in Galaxy history.
        If needed, StaticFile can be used to get a path where additional files can be put (e.g. generated image files).
        choices is a list of selections made by web-user in each options box.
        '''

        print 'Executing...'

        tempinfofile = ExternalTrackManager.extractFnFromGalaxyTN(
            choices[0].split(":"))
        abbrv = GenomeImporter.getGenomeAbbrv(tempinfofile)
        gi = GenomeInfo(abbrv)
        #chrNamesInFasta=gi.sourceChrNames
        chrNamesInFasta = cls._getTempChromosomeNames(choices[0]).split(
            os.linesep)

        chromNamesDict = {}
        chrDict = cls._getRenamedChrDictWithSelection(choices)

        for i, key in enumerate(chrDict.keys()):
            if chrDict[key]:
                chromNamesDict[chrNamesInFasta[i]] = key
        print 'All chromosomes chosen: ' + str(chromNamesDict)

        stdChrDict = cls._getRenamedChrDictWithSelection(choices, stdChrs=True)
        stdChrs = [x for x in stdChrDict if stdChrDict[x]]
        print 'Standard chromosomes chosen: ' + ", ".join(stdChrs)

        GenomeImporter.createGenome(abbrv,
                                    gi.fullName,
                                    chromNamesDict,
                                    stdChrs,
                                    username=username)

        gi.flagAsInstalled(username)
예제 #3
0
            print 'FAILED: Error occurred copying from %s to %s: ' % (
                fromDir, toDir) + str(e).strip()
            sys.exit(1)

    for track in ProcTrackOptions.getSubtypes('TestGenome',
                                              ['GESourceTracks']):
        ti = TrackInfo('TestGenome', ['GESourceTracks', track])
        ti.trackName = [track]
        ti.genome = 'ModelsForExternalTracks'
        ti.store()

    from quick.util.GenomeInfo import GenomeInfo
    from datetime import datetime
    gi = GenomeInfo('TestGenome')
    gi.fullName = 'TestGenome'
    gi.sourceUrls = ['http://hgdownload.cse.ucsc.edu/goldenPath/hg18/chromosomes/chr21.fa.gz', \
                     'http://hgdownload.cse.ucsc.edu/goldenPath/hg18/chromosomes/chrM.fa.gz']
    #gi.sourceChrNames = ['chr21', 'chrM']
    gi.genomeBuildSource = 'NCBI'
    gi.genomeBuildName = 'hg18'
    gi.species = 'H**o Sapiens'
    gi.speciesTaxonomyUrl = 'http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=9606'
    gi.assemblyDetails = 'Chromosome 21 and M from the hg18 genome, used for testing purposes.'
    gi.isPrivate = False
    gi.privateAccessList = []
    gi.isExperimental = False
    gi.flagAsInstalled(username='******')


extractTestGenomeAndPreProcess(galaxy_dir)