Ejemplo n.º 1
0
 def test_failure(self):
     """ Harvester should raise exception if clumpp generation sees weird line structure.
 """
     tmpDirParent = makeTempDirParent()
     tmpDirs = []
     for example in td.clumppLineStructure:
         tmpDirs.append(
             os.path.abspath(
                 makeTempDir('clumppLineStructure_%s' % example.name)))
         results = os.path.join(tmpDirs[-1], 'results')
         out = os.path.join(tmpDirs[-1], 'out')
         if not os.path.exists(out):
             os.mkdir(out)
         populateExample(example, tmpDirs[-1])
         files = glob(os.path.join(results, '*_f'))
         for f in files:
             data = hc.Data()
             data.records = {}  # key is K, value is an array
             run, errorString = hc.readFile(f, data)
             self.assertTrue(run is not None)
             data.records.setdefault(run.k, []).append(run)
         data.sortedKs = data.records.keys()
         data.sortedKs.sort()
         self.assertRaises(hc.ClumppLineStructure, hc.clumppPopFile,
                           results, out, data)
     [self.addCleanup(removeDir, d) for d in tmpDirs]
     self.addCleanup(removeDirIfEmpty, tmpDirParent)
Ejemplo n.º 2
0
def main():
    usage = (
        'usage: %(prog)s --dir=path/to/dir/ --out=path/to/dir/ [options]\n\n'
        '%(prog)s takes a STRUCTURE results directory (--dir) and an\n'
        'output directory (--out will be created if it does not exist) '
        'and then\n'
        'depending on the other options selected harvests data from the '
        'results\n'
        'directory and performs the selected analyses')
    data = hc.Data()
    parser = ArgumentParser(usage=usage,
                            version='%(prog)s ' + '%s core %s' %
                            (__version__, hc.__version__))
    initializeArguments(parser)
    args = parser.parse_args()
    checkArguments(parser, args)
    harvestFiles(data, args)
    hc.calculateMeansAndSds(data)
    if args.clumpp:
        try:
            hc.clumppGeneration(args.resultsDir, args.outDir, data)
        except hc.ClumppRegEx as e:
            clumppRegExFailure(e.filename, e.regexs, e.lineno, e.line, e.data)
        except hc.ClumppPriorPopInfo as e:
            clumppPriorPopInfoFailure(e.filename, data)
        try:
            hc.clumppPopFile(args.resultsDir, args.outDir, data)
        except hc.ClumppLineStructure as e:
            clumppLineStructureFailure(e.filename, e.regex, e.lineno, e.line,
                                       e.data)
    evannoMethod(data, args)
    hc.writeRawOutputToFile(os.path.join(args.outDir, 'summary.txt'), data)
Ejemplo n.º 3
0
 def test_failure(self):
     """ Harvester should raise exception if the input contains unexpected values.
 """
     tmpDirParent = makeTempDirParent()
     tmpDirs = []
     for example in td.readFileUnexpectedValue:
         tmpDirs.append(
             os.path.abspath(
                 makeTempDir('readFileUnexpected_%s' % example.name)))
         results = os.path.join(tmpDirs[-1], 'results')
         out = os.path.join(tmpDirs[-1], 'out')
         if not os.path.exists(out):
             os.mkdir(out)
         populateExample(example, tmpDirs[-1])
         files = glob(os.path.join(results, '*_f'))
         for f in files:
             data = hc.Data()
             data.records = {}  # key is K, value is an array
             self.assertRaises(hc.UnexpectedValue, hc.readFile, f, data)
     [self.addCleanup(removeDir, d) for d in tmpDirs]
     self.addCleanup(removeDirIfEmpty, tmpDirParent)
Ejemplo n.º 4
0
def main():
    usage = (
        'usage: %prog --dir=path/to/dir/ --out=path/to/dir/ [options]\n\n'
        '%prog takes a STRUCTURE results directory (--dir) and an\n'
        'output directory (--out will be created if it does not exist) and then\n'
        'depending on the other options selected harvests data from the results\n'
        'directory and performs the selected analyses')
    data = hc.Data()
    parser = OptionParser(usage=usage,
                          version='%prog ' + __version__ + ' core ' +
                          hc.__version__)
    initOptions(parser)
    (options, args) = parser.parse_args()
    checkOptions(parser, options)
    harvestFiles(data, options)
    hc.calculateMeansAndSds(data)
    if options.clumpp:
        hc.clumppGeneration(options.resultsDir, options.outDir, data,
                            failHandler)
        hc.clumppPopFile(options.resultsDir, options.outDir, data, failHandler)
    evannoMethod(data, options)
    hc.writeRawOutputToFile(os.path.join(options.outDir, 'summary.txt'), data)