Skip to content

Commit

Permalink
use ssl to open files
Browse files Browse the repository at this point in the history
  • Loading branch information
Veronika Csizmok committed Mar 5, 2024
1 parent 0dca27d commit d6658bc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"import seaborn as sns\n",
"from matplotlib.lines import Line2D\n",
"import warnings\n",
"import ssl\n",
"from urllib.request import urlopen\n",
"%matplotlib inline\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
Expand Down Expand Up @@ -349,9 +351,16 @@
" filename_methyl_fraction_non_BRC_OVA = r\"https://www.bcgsc.ca/downloads/nanopore_pog/ts_methylation//BRCA1_RAD51C_fraction_of_methylated_sites_non_BRC_OVA.tsv\"\n",
" filename_BRCA1_RAD51C_logTPM = r\"https://www.bcgsc.ca/downloads/nanopore_pog/ts_methylation//BRCA1_RAD51C_logTPM.tsv\"\n",
" \n",
" df_methyl_BRC_OVA = pd.read_csv(filename_methyl_fraction_BRC_OVA, sep = \"\\t\", index_col = \"tumour_original_source\")\n",
" df_methyl_non_BRC_OVA = pd.read_csv(filename_methyl_fraction_non_BRC_OVA, sep = \"\\t\", index_col = \"tumour_original_source\")\n",
" df_BRCA1_RAD51C_logTPM = pd.read_csv(filename_BRCA1_RAD51C_logTPM, sep = \"\\t\", index_col = \"tumour_original_source\")\n",
" context=ssl.create_default_context()\n",
" context.set_ciphers(\"DEFAULT\")\n",
" \n",
" result_BRC_OVA = urlopen(filename_methyl_fraction_BRC_OVA, context=context)\n",
" result_non_BRC_OVA = urlopen(filename_methyl_fraction_non_BRC_OVA, context=context)\n",
" result_BRCA1_RAD51C_logTPM = urlopen(filename_BRCA1_RAD51C_logTPM, context=context)\n",
" \n",
" df_methyl_BRC_OVA = pd.read_csv(result_BRC_OVA, sep = \"\\t\", index_col = \"tumour_original_source\")\n",
" df_methyl_non_BRC_OVA = pd.read_csv(result_non_BRC_OVA, sep = \"\\t\", index_col = \"tumour_original_source\")\n",
" df_BRCA1_RAD51C_logTPM = pd.read_csv(result_BRCA1_RAD51C_logTPM, sep = \"\\t\", index_col = \"tumour_original_source\")\n",
"\n",
"\n",
" generate_HRDetect_plot_BRC_OVA(df_methyl_BRC_OVA, df_methyl_non_BRC_OVA, PALETTE, OFFSET_METHYLATED)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"import numpy as np\n",
"from matplotlib.pylab import plt\n",
"from statsmodels.nonparametric.smoothers_lowess import lowess\n",
"import ssl\n",
"from urllib.request import urlopen\n",
"%matplotlib inline\n",
"\n",
"params = {\"font.family\":\"Arial\",\n",
Expand Down Expand Up @@ -73,10 +75,15 @@
" files_BRCA1 = BRCA1_files[tumour_type]\n",
" logger.info(\"generating BRCA1 haplotype plots for {}\".format(tumour_type))\n",
" \n",
" context=ssl.create_default_context()\n",
" context.set_ciphers(\"DEFAULT\")\n",
" \n",
" if len(files_BRCA1[0]) >0:\n",
" df_blood = pd.read_csv(files_BRCA1[0], sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" result_blood = urlopen(files_BRCA1[0], context=context)\n",
" df_blood = pd.read_csv(result_blood, sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" if len(files_BRCA1[1])>0:\n",
" df_tumour = pd.read_csv(files_BRCA1[1], sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" result_tumour = urlopen(files_BRCA1[1], context=context)\n",
" df_tumour = pd.read_csv(result_tumour, sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
"\n",
" \n",
" fig_BRCA1, ax_BRCA1 = plt.subplots(ncols=1, nrows=3, sharex = True, figsize = (8.5, 4.2), dpi = 600)\n",
Expand Down Expand Up @@ -217,10 +224,15 @@
" \n",
" files_RAD51C = RAD51C_files[tumour_type]\n",
" \n",
" context=ssl.create_default_context()\n",
" context.set_ciphers(\"DEFAULT\")\n",
" \n",
" if len(files_RAD51C[0]) >0:\n",
" df_blood = pd.read_csv(files_RAD51C[0], sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" result_blood = urlopen(files_RAD51C[0], context=context)\n",
" df_blood = pd.read_csv(result_blood, sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" if len(files_RAD51C[1])>0:\n",
" df_tumour = pd.read_csv(files_RAD51C[1], sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" result_tumour = urlopen(files_RAD51C[1], context=context)\n",
" df_tumour = pd.read_csv(result_tumour, sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
"\n",
" logger.info(\"generating RAD51C haplotype plots for {}\".format(tumour_type))\n",
"\n",
Expand Down Expand Up @@ -341,8 +353,13 @@
"\n",
" logger.info(\"generating MLH1 haplotype plots\")\n",
"\n",
" df_blood = pd.read_csv(filename_MLH1_blood, sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" df_tumour = pd.read_csv(filename_MLH1_tumour, sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" context=ssl.create_default_context()\n",
" context.set_ciphers(\"DEFAULT\")\n",
" \n",
" result_blood = urlopen(filename_MLH1_blood, context=context)\n",
" df_blood = pd.read_csv(result_blood, sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
" result_tumour = urlopen(filename_MLH1_tumour, context=context)\n",
" df_tumour = pd.read_csv(result_tumour, sep = \"\\t\", index_col = [\"gene\",\"start\", \"end\"])\n",
"\n",
" fig_MLH1, ax_MLH1 = plt.subplots(ncols=1, nrows=2, sharex = True, figsize = (5.2, 4), dpi = 600)\n",
" \n",
Expand Down

0 comments on commit d6658bc

Please sign in to comment.