Ejemplo 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')
Ejemplo n.º 2
0
"""



import os
import codecs

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import pandas as pd


from batch_query import Batch
from batch_analysis import BatchAnalysis, PatchExamination


sns.set(color_codes=True)

batch = Batch('./data/')
batch.scan_orded_folder()
concentation_list = ['0.3', '1', '3', '10', '100']

for concentration in concentation_list:
    cluster_list = batch.query(mutation = 'S270T', concentration = concentration)
    cluster_summary = BatchAnalysis(cluster_list)  
    summary = cluster_summary.compute_cluster_summary()
    np.savetxt(concentration+'.csv', summary, 
               fmt= ['%s', '%i', '%.2f', '%.2f','%.2f','%i','%.2f','%.2f'],
               delimiter = ',')
    
Ejemplo n.º 3
0
import os
import codecs

import matplotlib.pyplot as plt
import numpy as np
#import seaborn as sns
import pandas as pd


from batch_query import Batch
from batch_analysis import BatchAnalysis, PatchExamination


#sns.set(color_codes=True)

batch = Batch('/Users/zhiyiwu/Documents/pharmfit/data/')
batch.scan_orded_folder()
concentation_list = ['100',]
total = ''
amp = []
popen = []
errorbar = []
total_summary = pd.DataFrame()
for concentration in concentation_list:
    cluster_list = batch.query(mutation = 'wt', composition = 'alpha1beta', concentration = concentration)
    batch_analysis = BatchAnalysis(cluster_list)
    summary = batch_analysis.compute_cluster_summary()
    summary['start'] /= 1000
    summary['end'] /= 1000

    np.savetxt('temp.csv', summary, delimiter=',', fmt = '%s,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e')
Ejemplo n.º 4
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()
    

Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 20 09:21:42 2015

@author: zhiyiwu
"""
import os

import matplotlib.pyplot as plt
import numpy as np

from batch_query import Batch
from batch_analysis import BatchAnalysis

batch = Batch('/Users/zhiyiwu/GitHub/sc_py/data')
batch.scan_orded_folder()
list_100 = batch.query(mutation = 'wt', agonist = 'taurine', concentration = '100')
list_30 = batch.query(mutation = 'wt', agonist = 'taurine', concentration = '30')

combined_list = list_100 + list_30
for cluster in combined_list:
    cluster.compute_mode()
    cluster.compute_mode_detail(output = True)

batch_100 = BatchAnalysis(list_100)
cluster_100 = batch_100.compute_cluster_summary()
stretch_100 = batch_100.compute_stretch_summary()

popen_100 = plt.figure()
ax = popen_100.add_subplot(111)
ax.hist(stretch_100['popen'], bins = np.arange(0,1.05,0.05), color = 'blue')