Python config.data_dir() Examples

The following are 30 code examples of config.data_dir(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module config , or try the search function .
Example #1
Source File: test_pdb_chkensemble.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_ensemble_noendmdl2(self):
        """$ pdb_chkensemble data/ensemble_error_4.pdb"""

        fpath = os.path.join(data_dir, 'ensemble_error_4.pdb')
        sys.argv = ['', fpath]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(len(self.stderr), 1)

        self.assertEqual(self.stderr[0],
                         "ERROR!! MODEL record found before ENDMDL at line '6'") 
Example #2
Source File: test_pdb_chkensemble.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_ensemble_noendmdl(self):
        """$ pdb_chkensemble data/ensemble_error_3.pdb"""

        fpath = os.path.join(data_dir, 'ensemble_error_3.pdb')
        sys.argv = ['', fpath]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(len(self.stderr), 1)

        self.assertEqual(self.stderr[0],
                         "ERROR!! ENDMDL record missing at line '10'") 
Example #3
Source File: test_pdb_chkensemble.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_ensemble_nomodel(self):
        """$ pdb_chkensemble data/ensemble_error_2.pdb"""

        fpath = os.path.join(data_dir, 'ensemble_error_2.pdb')
        sys.argv = ['', fpath]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(len(self.stderr), 1)

        self.assertEqual(self.stderr[0],
                         "ERROR!! MODEL record missing before ATOM at line '3'") 
Example #4
Source File: test_pdb_chkensemble.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_ensemble_diffatom(self):
        """$ pdb_chkensemble data/ensemble_error_1.pdb"""

        fpath = os.path.join(data_dir, 'ensemble_error_1.pdb')
        sys.argv = ['', fpath]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(len(self.stderr), 3)

        self.assertEqual(self.stderr,
                         ["Models 1 and 2 differ:",
                          "Atoms in model 1 only:",
                          "    2  H   ASN A   1 "]) 
Example #5
Source File: test_pdb_occ.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_default(self):
        """$ pdb_occ data/dummy.pdb"""

        # Simulate input
        # pdb_occ dummy.pdb
        sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 0)  # ensure the program exited OK.
        self.assertEqual(len(self.stdout), 204)  # no lines deleted
        self.assertEqual(len(self.stderr), 0)  # no errors

        records = (('ATOM', 'HETATM'))
        occ_list = [l[54:60] for l in self.stdout if l.startswith(records)]
        unique_occ = list(set(map(float, occ_list)))
        self.assertEqual(unique_occ, [1.0])  # all occ values changed 
Example #6
Source File: test_pdb_chkensemble.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_valid_ensemble(self):
        """$ pdb_chkensemble data/ensemble_OK.pdb"""

        fpath = os.path.join(data_dir, 'ensemble_OK.pdb')
        sys.argv = ['', fpath]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 0)  # ensure the program exited OK.
        self.assertEqual(len(self.stdout), 1)
        self.assertEqual(len(self.stderr), 0)  # no errors

        self.assertEqual(self.stdout[0],
                         "Ensemble of 2 models *seems* OK") 
Example #7
Source File: test_pdb_tidy.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_default(self):
        """$ pdb_tidy data/dummy.pdb"""

        fpath = os.path.join(data_dir, 'dummy.pdb')
        sys.argv = ['', fpath]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 0)  # ensure the program exited OK.
        self.assertEqual(len(self.stdout), 207)
        self.assertEqual(len(self.stderr), 0)  # no errors

        # Check if we added TER statements correctly
        n_ter = len([r for r in self.stdout if r.startswith('TER')])
        self.assertEqual(n_ter, 5)

        # Check if we added END statements correctly
        self.assertTrue(self.stdout[-1].startswith('END')) 
Example #8
Source File: test_pdb_b.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_default(self):
        """$ pdb_b data/dummy.pdb"""

        # Simulate input
        # pdb_b -20 dummy.pdb
        sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 0)  # ensure the program exited OK.
        self.assertEqual(len(self.stdout), 204)  # no lines deleted
        self.assertEqual(len(self.stderr), 0)  # no errors

        records = (('ATOM', 'HETATM'))
        bfactors = [l[60:66] for l in self.stdout if l.startswith(records)]
        unique_bfac = list(set(map(float, bfactors)))
        self.assertEqual(unique_bfac, [10.00])  # all bfactors changed 
Example #9
Source File: test_pdb_gap.py    From pdb-tools with Apache License 2.0 6 votes vote down vote up
def test_default(self):
        """$ pdb_gap data/dummy.pdb"""

        # Simulate input
        sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 0)  # ensure the program exited OK.
        self.assertEqual(len(self.stdout), 5)  # no lines deleted
        self.assertEqual(len(self.stderr), 0)  # no errors

        self.assertEqual(self.stdout,
                         ["B:ARG4 < Seq. Gap > B:GLU6",
                          "A:ASN1 <    9.42A > A:ASN1",
                          "C:ARG5 < Seq. Gap > C:GLU2",
                          "C:GLU2 <   95.75A > C:MET-1",
                          "Found 4 gap(s) in the structure"]) 
Example #10
Source File: test_pdb_selchain.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_multiple(self):
        """
        $ pdb_selchain -A,B data/dummy.pdb
        """

        sys.argv = ['', '-A,B', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 0)
        self.assertEqual(len(self.stdout), 129)  # c.A + c.B
        self.assertEqual(len(self.stderr), 0) 
Example #11
Source File: test_pdb_delresname.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_file_not_found(self):
        """$ pdb_delresname not_existing.pdb"""

        afile = os.path.join(data_dir, 'not_existing.pdb')
        sys.argv = ['', afile]

        self.exec_module()

        self.assertEqual(self.retcode, 1)  # exit code is 1 (error)
        self.assertEqual(len(self.stdout), 0)  # nothing written to stdout
        self.assertEqual(self.stderr[0][:22],
                         "ERROR!! File not found")  # proper error message 
Example #12
Source File: test_pdb_delresname.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_not_an_option(self):
        """$ pdb_delresname 20 data/dummy.pdb"""

        sys.argv = ['', '20', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0],
                         "ERROR! First argument is not an option: '20'") 
Example #13
Source File: test_pdb_tidy.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_file_not_found(self):
        """$ pdb_tidy not_existing.pdb"""

        # Error (file not found)
        afile = os.path.join(data_dir, 'not_existing.pdb')
        sys.argv = ['', afile]

        # Execute the script
        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0][:22],
                         "ERROR!! File not found") 
Example #14
Source File: test_pdb_selchain.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_invalid_option(self):
        """$ pdb_selchain data/dummy.pdb"""

        sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0][:47],
                         "ERROR!! You must provide at least one chain ide") 
Example #15
Source File: test_pdb_selchain.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_one_option_CAPS_lowercase(self):
        """$ pdb_selchain -A data/dummy_az09.pdb"""

        # Simulate input
        # pdb_selchain dummy_az09.pdb
        sys.argv = ['', '-A', os.path.join(data_dir, 'dummy_az09.pdb')]

        # Execute the script
        self.exec_module()
        
        # Validate results
        self.assertEqual(self.retcode, 0)  # ensure the program exited OK.
        self.assertEqual(len(self.stdout), 76)  # selected c.A
        self.assertEqual(len(self.stderr), 0)  # no errors 
Example #16
Source File: test_pdb_selchain.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_one_option_digit(self):
        """$ pdb_selchain -1 data/dummy_az09.pdb"""

        # Simulate input
        # pdb_selchain dummy.pdb
        sys.argv = ['', '-1', os.path.join(data_dir, 'dummy_az09.pdb')]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 0)  # ensure the program exited OK.
        self.assertEqual(len(self.stdout), 71)  # selected c.1
        self.assertEqual(len(self.stderr), 0)  # no errors 
Example #17
Source File: test_pdb_chkensemble.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_invalid_option(self):
        """$ pdb_chkensemble -A data/dummy.pdb"""

        sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]

        # Execute the script
        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0][:36],
                         "ERROR!! Script takes 1 argument, not") 
Example #18
Source File: test_pdb_selchain.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_file_not_found(self):
        """$ pdb_selchain not_existing.pdb"""

        afile = os.path.join(data_dir, 'not_existing.pdb')
        sys.argv = ['', afile]

        self.exec_module()

        self.assertEqual(self.retcode, 1)  # exit code is 1 (error)
        self.assertEqual(len(self.stdout), 0)  # nothing written to stdout
        self.assertEqual(self.stderr[0][:22],
                         "ERROR!! File not found")  # proper error message 
Example #19
Source File: test_pdb_shiftres.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_too_many_residues(self):
        """$ pdb_shiftres -9998 data/dummy.pdb"""

        sys.argv = ['', '-9998', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(len(self.stderr), 1)

        self.assertEqual(self.stderr[0][:22],
                         "Cannot set residue num")  # proper error message 
Example #20
Source File: test_pdb_delresname.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_empty_sele(self):
        """$ pdb_delresname - data/dummy.pdb"""

        # Simulate input
        sys.argv = ['', '-', os.path.join(data_dir, 'dummy.pdb')]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0][:22],
                         "ERROR!! Residue name s") 
Example #21
Source File: test_pdb_delresname.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_multiple_sele(self):
        """$ pdb_delresname -ARG,CA data/dummy.pdb"""

        # Simulate input
        sys.argv = ['', '-ARG,CA', os.path.join(data_dir, 'dummy.pdb')]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 0)
        self.assertEqual(len(self.stdout), 127)
        self.assertEqual(len(self.stderr), 0) 
Example #22
Source File: test_pdb_delresname.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_single_sele(self):
        """$ pdb_delresname -ARG data/dummy.pdb"""

        # Simulate input
        sys.argv = ['', '-ARG', os.path.join(data_dir, 'dummy.pdb')]

        # Execute the script
        self.exec_module()

        # Validate results
        self.assertEqual(self.retcode, 0)
        self.assertEqual(len(self.stdout), 128)
        self.assertEqual(len(self.stderr), 0) 
Example #23
Source File: test_pdb_segxchain.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_invalid_option(self):
        """$ pdb_segxchain -A data/dummy.pdb"""

        sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]

        # Execute the script
        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0][:36],
                         "ERROR!! Script takes 1 argument, not") 
Example #24
Source File: test_pdb_segxchain.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_file_not_found(self):
        """$ pdb_segxchain not_existing.pdb"""

        # Error (file not found)
        afile = os.path.join(data_dir, 'not_existing.pdb')
        sys.argv = ['', afile]

        # Execute the script
        self.exec_module()

        self.assertEqual(self.retcode, 1)  # exit code is 1 (error)
        self.assertEqual(len(self.stdout), 0)  # nothing written to stdout
        self.assertEqual(self.stderr[0][:22],
                         "ERROR!! File not found")  # proper error message 
Example #25
Source File: test_pdb_selelem.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_not_an_option(self):
        """$ pdb_selelem 20 data/dummy.pdb"""

        sys.argv = ['', '20', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0],
                         "ERROR! First argument is not an option: '20'") 
Example #26
Source File: test_pdb_selelem.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_invalid_option_2(self):
        """$ pdb_selelem -ABC data/dummy.pdb"""

        sys.argv = ['', '-ABC', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0][:38],
                         "ERROR!! Element name is invalid: 'ABC'") 
Example #27
Source File: test_pdb_selelem.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_invalid_option(self):
        """$ pdb_selelem data/dummy.pdb"""

        sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0][:37],
                         "ERROR!! Element set cannot be empty") 
Example #28
Source File: test_pdb_selelem.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_file_not_found(self):
        """$ pdb_selelem not_existing.pdb"""

        afile = os.path.join(data_dir, 'not_existing.pdb')
        sys.argv = ['', afile]

        self.exec_module()

        self.assertEqual(self.retcode, 1)  # exit code is 1 (error)
        self.assertEqual(len(self.stdout), 0)  # nothing written to stdout
        self.assertEqual(self.stderr[0][:22],
                         "ERROR!! File not found")  # proper error message 
Example #29
Source File: test_pdb_selelem.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_multiple(self):
        """
        $ pdb_selelem -C,O data/dummy.pdb
        """

        sys.argv = ['', '-C,O', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 0)
        self.assertEqual(len(self.stdout), 75)
        self.assertEqual(len(self.stderr), 0) 
Example #30
Source File: test_pdb_b.py    From pdb-tools with Apache License 2.0 5 votes vote down vote up
def test_not_an_option(self):
        """$ pdb_b 20 data/dummy.pdb"""

        sys.argv = ['', '20', os.path.join(data_dir, 'dummy.pdb')]

        self.exec_module()

        self.assertEqual(self.retcode, 1)
        self.assertEqual(len(self.stdout), 0)
        self.assertEqual(self.stderr[0],
                         "ERROR! First argument is not an option: '20'")