Exemplo n.º 1
0
    def test_batch_query(self):
        '''
        test the batch_query module.
        '''
        cluster_list = []
        for patch in self._name_list:
            test_patch = Patch(os.path.join(self._dir, patch))
            test_patch.scan()
            for cluster in test_patch:
                cluster_list.append(cluster)
        # Test search orded folder scan
        choice_dict = OrderedDict([('receptor', ['NMDA', 'AMPA']),
                       ('mutation', ['S219P', 'S200T']),
                       ('composition', ['a1','ab']),
                       ('agonist', ['glycine', 'taurine']),
                       ('concentration', ['100', '0.1'])])

        organisation = {keys:{key: [] for key in choice_dict[keys]} for keys in choice_dict}

        for index in range(len(self._name_list)):
            temp_filepath = self._dir
            for key in choice_dict:
                choice = random.choice(choice_dict[key])
                temp_filepath = os.path.join(temp_filepath, choice)
                organisation[key][choice].extend([index]*self.cluster_num)
            try:
                os.makedirs(temp_filepath)
            except FileExistsError:
                pass
            shutil.copy2(os.path.join(self._dir, self._name_list[index]),
                      os.path.join(temp_filepath, self._name_list[index]))

        test_batch = Batch(folder_list = self._dir)
        if len(test_batch.scan_folder()) != len(cluster_list):
            print('scan_folder error')
        test_cluster_list = test_batch.scan_orded_folder(clear = True,export = True)
        copy_organisation = copy.deepcopy(organisation)
        for cluster in test_cluster_list:
            index = self._name_list.index(cluster.patchname)
            for key in organisation:
                if not index in organisation[key][getattr(cluster, key)]:
                    print('scan_orded_folder error')
                else:
                    copy_organisation[key][getattr(cluster, key)].remove(index)
        for i in copy_organisation:
            for j in copy_organisation[i]:
                if copy_organisation[i][j]:
                    print('scan_orded_folder error')

        # Test query
        copy_organisation = copy.deepcopy(organisation)
        for i in organisation:
            for j in organisation[i]:
                if organisation[i][j]:
                    query_list = test_batch.query(**{i: j})
                    for cluster in query_list:
                        index = self._name_list.index(cluster.patchname)
                        try:
                            copy_organisation[i][j].remove(index)
                        except ValueError:
                            print('query error')
        for i in copy_organisation:
            for j in copy_organisation[i]:
                if copy_organisation[i][j]:
                    print('query error')
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 16:14:24 2015

@author: zhiyiwu
"""

from batch_query import Batch
from PlotAnalysis import PlotSingle

a = Batch(['~/GitHub/Single_channel/HeteroData/',])
cluster_list = a.scan_folder()


for cluster in cluster_list:
    cluster.compute_mode()
    cluster.compute_mode_detail(True)
    c = PlotSingle('~/GitHub/sc_py/temp/')
    c.load_cluster(cluster)
#    c.plot_original()
#    c.plot_popen_on_original()
#    c.plot_open_close()
#    c.plot_cost_difference()
    c.plot_multitrace()