Skip to content

Commit

Permalink
Enable tqdm logger (#11)
Browse files Browse the repository at this point in the history
* initialize logger with tqdm

* removing redundant tqdm.pandas()

* adding pyarrow.parquet to phosphoproteomics

* removing unused imports

* fixed kinase-substrates typo
  • Loading branch information
harinlee0803 authored Dec 9, 2024
1 parent 5e4106e commit 6ef7acb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
4 changes: 4 additions & 0 deletions src/kinase_library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
from .modules.data import *
from .modules.enrichment import *

from .logger import TqdmToLoggerWithStatus, logger
tqdm_out = TqdmToLoggerWithStatus(logger)
tqdm.pandas(file=tqdm_out, ascii=False)

#%%

__version__ = "1.0.1"
Expand Down
4 changes: 0 additions & 4 deletions src/kinase_library/enrichment/binary_enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@
import pandas as pd
import scipy.stats as st
from statsmodels.stats import multitest
from tqdm import tqdm
tqdm.pandas()

from ..utils import _global_vars, exceptions, utils
from ..modules import data, enrichment
from ..objects import core
from ..objects import phosphoproteomics as pps
from ..logger import logger

#%%

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@
#####################################################
"""

import numpy as np
import pandas as pd
from tqdm import tqdm
import matplotlib.pyplot as plt
import warnings

from ..utils import _global_vars, exceptions
from ..modules import data, enrichment
from ..objects import core
from ..modules import enrichment
from ..objects import phosphoproteomics as pps
from ..enrichment import binary_enrichment as be
from ..logger import logger
tqdm.pandas()

plt.rcParams['font.family'] = 'Arial'
plt.rcParams['pdf.fonttype'] = 42
Expand Down
10 changes: 3 additions & 7 deletions src/kinase_library/enrichment/mea.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
########################################################
"""

import numpy as np
import pandas as pd
from tqdm import tqdm
import gseapy as gp
tqdm.pandas()

from ..utils import _global_vars, exceptions, utils
from ..utils import _global_vars, exceptions
from ..modules import data, enrichment
from ..objects import core
from ..objects import phosphoproteomics as pps
from ..logger import logger

Expand Down Expand Up @@ -105,8 +101,8 @@ def submit_percentiles(self, kin_type, percentiles, phosprot_name=None, suppress

def _create_kin_sub_sets(self, thresh, comp_direction):

print('\nGenerating kinase-substartes sets')
logger.info('Generating kinase-substartes sets')
print('\nGenerating kinase-substrates sets')
logger.info('Generating kinase-substrates sets')
kin_sub_sets = enrichment.create_kin_sub_sets(data_values=self.data_kl_values, threshold=thresh, comp_direction=comp_direction)
self.kin_sub_sets = kin_sub_sets

Expand Down
11 changes: 2 additions & 9 deletions src/kinase_library/objects/phosphoproteomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
# The Kinase Library - Phosphoproteomics #
##########################################
"""

import os
import numpy as np
import pandas as pd
import scipy.stats as st
from statsmodels.stats import multitest
from tqdm import tqdm
import gseapy as gp
tqdm.pandas()
import pyarrow.parquet as pq

from ..utils import _global_vars, exceptions, utils
from ..modules import data, enrichment
from ..modules import data
from . import core
from ..logger import logger

Expand Down Expand Up @@ -461,7 +455,6 @@ def percentile(self, kin_type=None, kinases=None,

print('Calculating percentile for '+str(len(getattr(self,kin_type+'_substrates')))+' '+kin_type+' substrates')
logger.info('Calculating percentile for '+str(len(getattr(self,kin_type+'_substrates')))+' '+kin_type+' substrates')
tqdm.pandas()
percent_output = scored_phosprot.progress_apply(lambda x: x.sort_values().searchsorted(score[x.name], side='right'))/len(scored_phosprot)*100
percent_output.index = score.index

Expand Down

0 comments on commit 6ef7acb

Please sign in to comment.