Ejemplo n.º 1
0
    def run_mem_estimator(self, ctx, params):
        """
        This is a local function that estimates how much memory SPAdes or metaSPAdes needs
        to assemble a paired end library.
        Returns a float, representing the estimated memory use in GB.
        :param params: instance of type "MemEstimatorParams" (reads_file -
           path to a paired end reads file. If this is here alone, expect it
           to be interleaved. reads_file2 - path to the pair of the first
           file.) -> structure: parameter "reads_file" of String, parameter
           "reads_file2" of String
        :returns: instance of type "MemEstimatorOutput" (estimate - the
           estimated amount of memory required to assemble the paired end
           files, in GB.) -> structure: parameter "estimate" of Double
        """
        # ctx is the context object
        # return variables are: output
        #BEGIN run_mem_estimator
        runner = MemEstimatorRunner(params)
        output = runner.run()
        #END run_mem_estimator

        # At some point might do deeper type checking...
        if not isinstance(output, dict):
            raise ValueError('Method run_mem_estimator return value ' +
                             'output is not type dict as required.')
        # return the results
        return [output]
Ejemplo n.º 2
0
 def test_mem_estimator_ok_unit(self):
     in_file = os.path.join('data', 'reads', 'interleaved.fastq')
     params = {"reads_file": in_file}
     runner = MemEstimatorRunner(params)
     estimate = runner.run()
     self.assertGreater(estimate["estimate"], 0)
     self.assertGreater(estimate["size"], 0)
Ejemplo n.º 3
0
 def test_mem_estimator_ok_pair(self):
     params = {
         "reads_file": os.path.join('data', 'reads', 'small.forward.fq'),
         "reads_file2": os.path.join('data', 'reads', 'small.reverse.fq')
     }
     runner = MemEstimatorRunner(params)
     estimate = runner.run()
     self.assertGreater(estimate["estimate"], 0)
     self.assertGreater(estimate["size"], 0)
Ejemplo n.º 4
0
 def test_mem_estimator_pair_dups(self):
     in_file = os.path.join('data', 'reads', 'interleaved.fastq')
     params = {"reads_file": in_file, "reads_file2": in_file}
     with self.assertRaises(ValueError) as e:
         MemEstimatorRunner(params)
     self.assertIn("If two files are present, they must be different.",
                   str(e.exception))
Ejemplo n.º 5
0
    def test_bad_inputs(self):
        impl = self.getImpl()
        ctx = self.getContext()
        with self.assertRaises(ValueError) as e:
            MemEstimatorRunner({})
        self.assertIn('Parameter "reads_file" must be present!',
                      str(e.exception))

        with self.assertRaises(ValueError) as e:
            impl.run_mem_estimator(ctx, {"reads_file": "not_real"})
        self.assertIn(
            "The file not_real does not seem to exist, or is a directory",
            str(e.exception))

        with self.assertRaises(ValueError) as e:
            impl.run_mem_estimator(
                ctx, {
                    "reads_file":
                    os.path.join('data', 'reads', 'interleaved.fastq'),
                    "reads_file2":
                    "not_real2"
                })
        self.assertIn(
            "The file not_real2 does not seem to exist, or is a directory",
            str(e.exception))
Ejemplo n.º 6
0
 def test_mem_estimator_bad_file(self):
     in_file = os.path.join('data', 'reads', 'bad_reads.txt')
     params = {"reads_file": in_file}
     with self.assertRaises(ValueError) as e:
         MemEstimatorRunner(params).run()
     self.assertIn("Count of unique 31-mers not found.", str(e.exception))
     self.assertNotIn("31-mers processed", str(e.exception))
     self.assertNotIn("Correct 31-mers", str(e.exception))
     self.assertNotIn("Unique 31-mers", str(e.exception))