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

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

        rmtree(test_dir)
Ejemplo n.º 4
0
    def test_sample_fasta(self):
        """RdpClassifier should classify its own sample data correctly"""
        test_dir = '/tmp/RdpTest'
        app = RdpClassifier(WorkingDir=test_dir)
        _, output_fp = tempfile.mkstemp(dir=test_dir)
        app.Parameters['-o'].on(output_fp)        

        results = app(StringIO(rdp_sample_fasta))

        assignment_toks = results['Assignments'].readline().split('\t')

        self.assertEqual(assignment_toks[0], 'X67228')
        lineage = [x.strip('"') for x in assignment_toks[2::3]]
        self.assertEqual(lineage, [
            'Root', 'Bacteria', 'Proteobacteria', 'Alphaproteobacteria',
            'Rhizobiales', 'Rhizobiaceae', 'Rhizobium'])
        rmtree(test_dir)
Ejemplo n.º 5
0
    def test_sample_fasta(self):
        """RdpClassifier should classify its own sample data correctly"""
        test_dir = '/tmp/RdpTest'
        app = RdpClassifier(WorkingDir=test_dir)

        results = app(rdp_sample_fasta)
        results_file = results['StdOut']
        
        id_line = results_file.readline()
        self.failUnless(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)
Ejemplo n.º 6
0
 def test_basecommand_property(self):
     """RdpClassifier BaseCommand property should use overridden method."""
     app = RdpClassifier()
     self.assertEqual(app.BaseCommand, app._get_base_command())
Ejemplo n.º 7
0
 def test_basecommand_property(self):
     """RdpClassifier BaseCommand property should use overridden method."""
     app = RdpClassifier()
     self.assertEqual(app.BaseCommand, app._get_base_command())
Ejemplo n.º 8
0
 def test_parameters_list(self):
     a = RdpClassifier()
     parameters = list(a.Parameters.keys())
     parameters.sort()
     self.assertEqual(parameters, ['-Xmx', '-f', '-o', '-t'])
Ejemplo n.º 9
0
 def test_default_java_vm_parameters(self):
     """RdpClassifier should store default arguments to Java VM."""
     a = RdpClassifier()
     self.assertContains(a.Parameters, '-Xmx')
     self.assertEqual(a.Parameters['-Xmx'].Value, '1000m')
Ejemplo n.º 10
0
 def test_default_positional_parameters(self):
     """RdpClassifier should store default positional arguments."""
     a = RdpClassifier()
     self.assertContains(a.PositionalParameters, '-training-data')
     self.assertEqual(a.PositionalParameters['-training-data'].Value, '')        
Ejemplo n.º 11
0
 def test_positional_parameters_list(self):
     a = RdpClassifier()
     parameters = a.PositionalParameters.keys()
     parameters.sort()
     self.assertEqual(parameters, ['-training-data'])
Ejemplo n.º 12
0
 def test_jvm_parameters_list(self):
     a = RdpClassifier()
     parameters = a.JvmParameters.keys()
     parameters.sort()
     self.assertEqual(parameters, ['-Xmx'])