Example #1
0
 def test_base_command(self):
     """RdpClassifier should return expected shell command."""
     app = RdpClassifier20()
     exp = ''.join([
         'cd "',
         getcwd(), '/"; java -Xmx1000m -jar "', self.user_rdp_jar_path, '"'
     ])
     self.assertEqual(app.BaseCommand, exp)
Example #2
0
 def test_assign_jvm_parameters(self):
     """RdpCalssifier should pass alternate parameters to Java VM."""
     app = RdpClassifier20()
     app.Parameters['-Xmx'].on('75M')
     exp = ''.join([
         'cd "',
         getcwd(), '/"; java -Xmx75M -jar "', self.user_rdp_jar_path, '"'
     ])
     self.assertEqual(app.BaseCommand, exp)
    def test_change_working_dir(self):
        """RdpClassifier should run program in expected working directory."""
        test_dir = '/tmp/RdpTest'

        app = RdpClassifier20(WorkingDir=test_dir)
        exp = ''.join(['cd "', test_dir, '/"; java -Xmx1000m -jar "', self.user_rdp_jar_path, '"'])
        self.assertEqual(app.BaseCommand, exp)

        rmtree(test_dir)
    def test_sample_fasta(self):
        """RdpClassifier should classify its own sample data correctly"""
        test_dir = '/tmp/RdpTest'
        app = RdpClassifier20(WorkingDir=test_dir)

        results = app(rdp_sample_fasta)
        results_file = results['Assignments']
        
        id_line = results_file.readline()
        self.assertTrue(id_line.startswith('>X67228'))

        classification_line = results_file.readline().strip()
        obs = parse_rdp(classification_line)
        exp = ['Root', 'Bacteria', 'Proteobacteria', 'Alphaproteobacteria', 'Rhizobiales', 'Rhizobiaceae', 'Rhizobium']
        self.assertEqual(obs, exp)

        rmtree(test_dir)
Example #5
0
 def test_basecommand_property(self):
     """RdpClassifier BaseCommand property should use overridden _get_base_command method."""
     app = RdpClassifier20()
     self.assertEqual(app.BaseCommand, app._get_base_command())
Example #6
0
 def test_default_positional_parameters(self):
     """RdpClassifier should store default positional arguments."""
     a = RdpClassifier20()
     self.assertContains(a.PositionalParameters, '-training-data')
     self.assertEqual(a.PositionalParameters['-training-data'].Value, '')
Example #7
0
 def test_positional_parameters_list(self):
     a = RdpClassifier20()
     parameters = a.PositionalParameters.keys()
     parameters.sort()
     self.assertEqual(parameters, ['-training-data'])
Example #8
0
 def test_jvm_parameters_list(self):
     a = RdpClassifier20()
     parameters = a.JvmParameters.keys()
     parameters.sort()
     self.assertEqual(parameters, ['-Xmx'])
Example #9
0
 def test_default_java_vm_parameters(self):
     """RdpClassifier should store default arguments to Java VM."""
     a = RdpClassifier20()
     self.assertContains(a.Parameters, '-Xmx')
     self.assertEqual(a.Parameters['-Xmx'].Value, '1000m')
 def test_parameters_list(self):
     a = RdpClassifier20()
     parameters = list(a.Parameters.keys())
     parameters.sort()
     self.assertEqual(parameters, ['-Xmx', '-training-data'])