def test_sql_file_not_exists(self):
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -k'+
                            ' -digits 3 -sql /tmp/scipion.sql -filename DMY_ABC_0001.mrc')
     if os.path.isfile('/tmp/scipion.sql'):
         os.remove('/tmp/scipion.sql')
     with self.assertRaises(IOError):
         with patch('sys.stdout', new=MagicMock()):
                 obj = s.starfleet_master(sys.argv)
 def test_nonexist_microg_folder_and_force(self):
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -k'+
                            ' -digits 3 -files_list 1 2 3 -filename DMY_ABC_0001.mrc '+
                            '-image_folder nonexisting/ -f')
     with open('/tmp/in.star', 'w+b'):
         pass
     obj = s.starfleet_master(sys.argv)
     self.assertEqual(1, obj.check)
 def setUp(self):
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -k '+
                            ' -digits 4 -filename a_0001.mrc -image_folder /tmp'+
                            ' -sql /tmp/scipion.sql')
     with open('/tmp/in.star', 'w') as f:
         f.write(normal_starfile)
     with open('/tmp/scipion.sql', 'w') as f:
         f.write(sql_file)
     self.obj = s.starfleet_master(sys.argv)
 def setUp(self):
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -make_ctf '+
                            ' -digits 4 -filename 20160126_BRCA1_GO_0001.mrc')
     self.epa_list = ['20160126_BRCA1_GO_0092_ctffind.log', '20160126_BRCA1_GO_0002_ctffind.log', 
                 '20160126_BRCA1_GO_0091_ctffind.log', '20160126_BRCA1_GO_0001_ctffind.log']
     with open('/tmp/in.star', 'w') as f:
         f.write(normal_starfile)
     self.obj = s.starfleet_master(sys.argv)
     self.obj.read_star()
     self.obj.create_epa_list()  
 def test_remove_mode_ctf_starfile(self):
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -r -files_list 91 92'+
                            ' -digits 4 -filename 20160126_BRCA1_GO_0001.mrc')
     with open('/tmp/in.star', 'w') as f:
         f.write(ctf_starfile)
     obj = s.starfleet_master(sys.argv)
     obj.read_star()
     obj.write_star()
     with open(obj.o, 'r') as f:
         self.assertMultiLineEqual(f.read(), self.exp_ctf_starfile)
 def test_ctf_starfile_in(self):
      
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -k -files_list 1 2 3'+
                            ' -digits 4 -filename 20160126_BRCA1_GO_0001.mrc')
     with open('/tmp/in.star', 'w') as f:
         f.write(ctf_starfile)
     obj = s.starfleet_master(sys.argv)
     h,f = obj.read_star()
     self.assertEqual(self.ctf_header, ''.join(obj.header))
     self.assertEqual(self.ctf_header, ''.join(h))
     self.assertEqual(self.ctf_files, obj.files_in)
     self.assertEqual(self.ctf_files, f)
 def setUp(self):
     for i in ['20160126_BRCA1_GO_0001.mrc',
               '20160126_BRCA1_GO_0002.mrc',
               '20160126_BRCA1_GO_0091.mrc',
               '20160126_BRCA1_GO_0092.mrc']:
         
         with open(('/tmp/'+i), 'w+b'):
             pass
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -k -files_list 1 2 92 93'+
                            ' -digits 4 -filename 20160126_BRCA1_GO_0001.mrc -image_folder /tmp')
     with open('/tmp/in.star', 'w') as f:
         f.write(normal_starfile)
     self.obj = s.starfleet_master(sys.argv)
     h,f = self.obj.read_star()     
 def test_nonexist_microg_folder_and_not_force(self):
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -k'+
                            ' -digits 3 -files_list 1 2 3 -filename DMY_ABC_0001.mrc '+
                            ' -image_folder nonexisting/')
     with self.assertRaises(IOError):
         s.starfleet_master(sys.argv)
 def test_list_in_parsed_arguments(self):
     os.remove('/tmp/out.star')
     self.assertEqual(['001','002'], 
                      s.starfleet_master(sys.argv).lst)
 def test_input_file_not_exists(self):
     if os.path.isfile('/tmp/in.star'):
         os.remove('/tmp/in.star')
     with self.assertRaises(IOError):
         s.starfleet_master(sys.argv)
 def test_no_sql_no_files_list_make_ctf(self):
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star '+
                            ' -digits 3 -filename DMY_ABC_0001.mrc -make_ctf')
     with open('/tmp/in.star','w'):
         pass
     self.assertTrue(s.starfleet_master(sys.argv).check)
 def test_no_sql_no_files_list(self):
     sys.argv = shlex.split('test.py -i /tmp/in.star -o /tmp/out.star -k'+
                            ' -digits 3 -filename DMY_ABC_0001.mrc')
     with self.assertRaises(ValueError):
         with patch('sys.stdout', new=MagicMock()):
                 obj = s.starfleet_master(sys.argv)