@@ -0,0 +1,1851 @@
+import sys, os, re, shutil%0Afrom nose.tools import *%0A%0Aimport logging%0Alogger = logging.getLogger(__name__)%0A%0Asys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))%0Afrom qipipe.interfaces import MapCTP%0A%0AROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))%0A%22%22%22The test parent directory.%22%22%22%0A%0ARESULTS = os.path.join(ROOT, 'results', 'staging', 'map_ctp')%0A%22%22%22The test results directory.%22%22%22%0A%0Afrom nipype import config%0Acfg = dict(logging=dict(workflow_level='DEBUG', log_directory=RESULTS, log_to_file=True),%0A    execution=dict(crashdump_dir=RESULTS, create_report=False))%0Aconfig.update_config(cfg)%0A%0ACOLLECTION = 'Sarcoma'%0A%22%22%22The test collection.%22%22%22%0A%0ASUBJECTS = %5B%22Sarcoma%2502d%22 %25  i for i in range(8, 12)%5D%0A%0APAT = %22ptid/(Sarcoma%5Cd%7B2%7D)%5Cs*=%5Cs*QIN-%5Cw+-%5Cd%7B2%7D-(%5Cd%7B4%7D)%22%0A%0Aclass TestMapCTP:%0A    %22%22%22Map CTP unit tests.%22%22%22%0A    %0A    def tearDown(self):%0A        shutil.rmtree(RESULTS, True)%0A    %0A    def test_map_ctp(self):%0A        logger.debug(%22Testing Map CTP on %25s...%22 %25 SUBJECTS)%0A        map_ctp = MapCTP(collection=COLLECTION, patient_ids=SUBJECTS, dest=RESULTS)%0A        result = map_ctp.run()%0A        prop_file = result.outputs.out_file%0A        assert_true(os.path.exists(prop_file), %22Property file was not created: %25s%22 %25 prop_file)%0A        assert_equal(RESULTS, os.path.dirname(prop_file), %22Property file was not created in %25s: %25s%22 %25 (RESULTS, prop_file))%0A        for line in open(prop_file).readlines():%0A            qin_id, ctp_suffix = re.match(PAT, line).groups()%0A            assert_true(qin_id in SUBJECTS, %22Subject id not found: %25s%22 %25 qin_id)%0A            qin_nbr = int(qin_id%5B-2:%5D)%0A            ctp_nbr = int(ctp_suffix)%0A            assert_equal(qin_nbr, ctp_nbr, %22Patient number incorrect; expected: %25d found: %25d%22 %25 (qin_nbr, ctp_nbr))%0A%0A%0Aif __name__ == %22__main__%22:%0A    import nose%0A    %0A    nose.main(defaultTest=__name__)%0A

Test the Map CTP interface.