about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBonfaceKilz2020-08-27 01:18:11 +0300
committerBonfaceKilz2020-08-27 01:42:41 +0300
commit357ca458695fbc60c97de3d1cdf89034a8722bc5 (patch)
tree54179a761cb25a871370d7a815eed97d5e0497df
parent768de71f09b116cad0f42c792c22a7dc410ea2f4 (diff)
downloadgenenetwork2-357ca458695fbc60c97de3d1cdf89034a8722bc5.tar.gz
Replace "string.split" & "string.join" with python's inbuilt methods
-rwxr-xr-xscripts/maintenance/readProbeSetMean_v7.py20
-rwxr-xr-xscripts/maintenance/readProbeSetSE_v7.py14
-rw-r--r--wqflask/base/data_set.py2
-rw-r--r--wqflask/base/trait.py14
-rw-r--r--wqflask/utility/webqtlUtil.py4
-rw-r--r--wqflask/wqflask/external_tools/send_to_geneweaver.py2
-rw-r--r--wqflask/wqflask/external_tools/send_to_webgestalt.py2
-rw-r--r--wqflask/wqflask/interval_analyst/GeneUtil.py4
-rw-r--r--wqflask/wqflask/marker_regression/display_mapping_results.py2
-rw-r--r--wqflask/wqflask/marker_regression/plink_mapping.py6
-rw-r--r--wqflask/wqflask/show_trait/show_trait.py4
-rw-r--r--wqflask/wqflask/snp_browser/snp_browser.py12
12 files changed, 43 insertions, 43 deletions
diff --git a/scripts/maintenance/readProbeSetMean_v7.py b/scripts/maintenance/readProbeSetMean_v7.py
index a540796a..43f084f4 100755
--- a/scripts/maintenance/readProbeSetMean_v7.py
+++ b/scripts/maintenance/readProbeSetMean_v7.py
@@ -60,15 +60,15 @@ print('Checking if each line have same number of members')
 GeneList = []
 isCont = 1
 header = fp.readline()
-header = string.split(string.strip(header), '\t')
-header = list(map(string.strip, header))
+header = header.strip().split('\t')
+header = [x.strip() for x in header]
 nfield = len(header)
 line = fp.readline()
 
 kj = 0
 while line:
-    line2 = string.split(string.strip(line), '\t')
-    line2 = list(map(string.strip, line2))
+    line2 = line.strip().split('\t')
+    line2 = [x.strip() for x in line2]
     if len(line2) != nfield:
         print(("Error : " + line))
         isCont = 0
@@ -98,8 +98,8 @@ print('Checking if each strain exist in database')
 isCont = 1
 fp.seek(0)
 header = fp.readline()
-header = string.split(string.strip(header), '\t')
-header = list(map(string.strip, header))
+header = header.strip().split('\t')
+header = [x.strip() for x in header]
 header = list(map(translateAlias, header))
 header = header[dataStart:]
 Ids = []
@@ -126,8 +126,8 @@ print('Check if each ProbeSet exist in database')
 ##---- find PID is name or target ----##
 line = fp.readline()
 line = fp.readline()
-line2 = string.split(string.strip(line), '\t')
-line2 = list(map(string.strip, line2))
+line2 = line.strip().split('\t')
+line2 = [x.strip() for x in line2]
 PId = line2[0]
 
 db.execute('select Id from ProbeSet where Name="%s" and ChipId=%d' %
@@ -222,8 +222,8 @@ kj = 0
 values1 = []
 values2 = []
 while line:
-    line2 = string.split(string.strip(line), '\t')
-    line2 = list(map(string.strip, line2))
+    line2 = line.strip().split('\t')
+    line2 = [x.strip() for x in line2]
     PId = line2[0]
     recordId = NameIds[PId]
 
diff --git a/scripts/maintenance/readProbeSetSE_v7.py b/scripts/maintenance/readProbeSetSE_v7.py
index 20a846a4..edd9e7b0 100755
--- a/scripts/maintenance/readProbeSetSE_v7.py
+++ b/scripts/maintenance/readProbeSetSE_v7.py
@@ -71,14 +71,14 @@ print('Checking if each line have same number of members')
 GeneList = []
 isCont = 1
 header = fp.readline()
-header = string.split(string.strip(header), '\t')
+header = header.strip().split('\t')
 header = list(map(string.strip, header))
 nfield = len(header)
 line = fp.readline()
 
 kj = 0
 while line:
-    line2 = string.split(string.strip(line), '\t')
+    line2 = line.strip().split('\t')
     line2 = list(map(string.strip, line2))
     if len(line2) != nfield:
         isCont = 0
@@ -109,7 +109,7 @@ print('Checking if each strain exist in database')
 isCont = 1
 fp.seek(0)
 header = fp.readline()
-header = string.split(string.strip(header), '\t')
+header = header.strip().split('\t')
 header = list(map(string.strip, header))
 header = list(map(translateAlias, header))
 header = header[dataStart:]
@@ -137,8 +137,8 @@ print('Check if each ProbeSet exist in database')
 ##---- find PID is name or target ----##
 line = fp.readline()
 line = fp.readline()
-line2 = string.split(string.strip(line), '\t')
-line2 = list(map(string.strip, line2))
+line2 = line.strip().split('\t')
+line2 = [x.strip() for x in line2]
 PId = line2[0]
 
 db.execute('select Id from ProbeSet where Name="%s" and ChipId=%d' %
@@ -217,8 +217,8 @@ line = fp.readline()
 
 kj = 0
 while line:
-    line2 = string.split(string.strip(line), '\t')
-    line2 = list(map(string.strip, line2))
+    line2 = line.strip().split('\t')
+    line2 = [x.strip() for x in line2]
 
     CellId = line2[0]
     if CellId not in ProbeNameId:
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 8ac7a279..ce017fb4 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -697,7 +697,7 @@ class DataSet(object):
             else:
                 query = "SELECT {}.Name,".format(escape(dataset_type))
             data_start_pos = 1
-            query += string.join(temp, ', ')
+            query += ', '.join(temp)
             query += ' FROM ({}, {}XRef, {}Freeze) '.format(*mescape(dataset_type,
                                                                      self.type,
                                                                      self.type))
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index b20efd2a..2fd5d725 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -150,8 +150,8 @@ class GeneralTrait(object):
 
         alias = 'Not available'
         if getattr(self, "alias", None):
-            alias = string.replace(self.alias, ";", " ")
-            alias = string.join(string.split(alias), ", ")
+            alias = self.alias.replace(";", " ")
+            alias = ", ".join(alias.split())
 
         return alias
 
@@ -437,7 +437,7 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
         #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name
         # to avoid the problem of same marker name from different species.
         elif dataset.type == 'Geno':
-            display_fields_string = string.join(dataset.display_fields, ',Geno.')
+            display_fields_string = ',Geno.'.join(dataset.display_fields)
             display_fields_string = 'Geno.' + display_fields_string
             query = """
                     SELECT %s
@@ -456,8 +456,8 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
             query = """SELECT %s FROM %s WHERE Name = %s"""
             logger.sql(query)
             trait_info = g.db.execute(query,
-                                    (string.join(dataset.display_fields, ','),
-                                                dataset.type, trait.name)).fetchone()
+                                      ','.join(dataset.display_fields),
+                                      dataset.type, trait.name).fetchone()
 
     if trait_info:
         trait.haveinfo = True
@@ -501,8 +501,8 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
                 trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % trait.pubmed_id
 
         if dataset.type == 'ProbeSet' and dataset.group:
-            description_string = str(str(trait.description).strip(codecs.BOM_UTF8), 'utf-8')
-            target_string = str(str(trait.probe_target_description).strip(codecs.BOM_UTF8), 'utf-8')
+            description_string = trait.description
+            target_string = trait.probe_target_description
 
             if len(description_string) > 1 and description_string != 'None':
                 description_display = description_string
diff --git a/wqflask/utility/webqtlUtil.py b/wqflask/utility/webqtlUtil.py
index d4979011..5681fadf 100644
--- a/wqflask/utility/webqtlUtil.py
+++ b/wqflask/utility/webqtlUtil.py
@@ -107,7 +107,7 @@ def hasAccessToConfidentialPhenotypeTrait(privilege, userName, authorized_users)
     if webqtlConfig.USERDICT[privilege] > webqtlConfig.USERDICT['user']:
         access_to_confidential_phenotype_trait = 1
     else:
-        AuthorizedUsersList=list(map(string.strip, string.split(authorized_users, ',')))
-        if AuthorizedUsersList.__contains__(userName):
+        AuthorizedUsersList=[x.strip() for x in authorized_users.split(',')]
+        if userName in AuthorizedUsersList:
             access_to_confidential_phenotype_trait = 1
     return access_to_confidential_phenotype_trait
diff --git a/wqflask/wqflask/external_tools/send_to_geneweaver.py b/wqflask/wqflask/external_tools/send_to_geneweaver.py
index 93164233..4c958a88 100644
--- a/wqflask/wqflask/external_tools/send_to_geneweaver.py
+++ b/wqflask/wqflask/external_tools/send_to_geneweaver.py
@@ -55,7 +55,7 @@ class SendToGeneWeaver(object):
                                  'client': "genenetwork",
                                  'species': species_name,
                                  'idtype': self.chip_name,
-                                 'list': string.join(trait_name_list, ","),
+                                 'list': ",".join(trait_name_list),
                                }
 
 def get_trait_name_list(trait_list):
diff --git a/wqflask/wqflask/external_tools/send_to_webgestalt.py b/wqflask/wqflask/external_tools/send_to_webgestalt.py
index b255ba95..2f068792 100644
--- a/wqflask/wqflask/external_tools/send_to_webgestalt.py
+++ b/wqflask/wqflask/external_tools/send_to_webgestalt.py
@@ -47,7 +47,7 @@ class SendToWebGestalt(object):
             id_type = "entrezgene"
 
             self.hidden_vars = { 
-                             'gene_list'                  : string.join(gene_id_list, "\n"),
+                             'gene_list'                  : "\n".join(gene_id_list),
                              'id_type'                    : "entrezgene",
                              'ref_set'                    : "genome",
                              'enriched_database_category' : "geneontology",
diff --git a/wqflask/wqflask/interval_analyst/GeneUtil.py b/wqflask/wqflask/interval_analyst/GeneUtil.py
index 17c8ccbf..d0dd7aea 100644
--- a/wqflask/wqflask/interval_analyst/GeneUtil.py
+++ b/wqflask/wqflask/interval_analyst/GeneUtil.py
@@ -31,7 +31,7 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'):
                       Chromosome = '%s' AND
 					  ((TxStart > %f and TxStart <= %f) OR (TxEnd > %f and TxEnd <= %f))
 				ORDER BY txStart
-                """ % (string.join(fetchFields, ", "),
+                """ % (", ".join(fetchFields),
                        speciesId, chrName,
                        startMb, endMb,
                        startMb, endMb)).fetchall()
@@ -66,7 +66,7 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'):
 				othSpec, othSpecId = item
 				newdict2 = {}
 				
-				resultsOther = g.db.execute("SELECT %s FROM GeneList WHERE SpeciesId = %d AND geneSymbol= '%s' LIMIT 1" % (string.join(fetchFields, ", "),
+				resultsOther = g.db.execute("SELECT %s FROM GeneList WHERE SpeciesId = %d AND geneSymbol= '%s' LIMIT 1" % (", ".join(fetchFields),
                                                                                                                            othSpecId,
                                                                                                                            newdict["GeneSymbol"])).fetchone()
 
diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py
index ccdafa14..dfaa1562 100644
--- a/wqflask/wqflask/marker_regression/display_mapping_results.py
+++ b/wqflask/wqflask/marker_regression/display_mapping_results.py
@@ -454,7 +454,7 @@ class DisplayMappingResults(object):
                         Chr_Length.Name in (%s)
                 Order by
                         Chr_Length.OrderId
-                """ % (self.dataset.group.name, string.join(["'%s'" % X[0] for X in self.ChrList[1:]], ", ")))
+                """ % (self.dataset.group.name, ", ".join(["'%s'" % X[0] for X in self.ChrList[1:]])))
 
         self.ChrLengthMbList = [x[0]/1000000.0 for x in self.ChrLengthMbList]
         self.ChrLengthMbSum = reduce(lambda x, y:x+y, self.ChrLengthMbList, 0.0)
diff --git a/wqflask/wqflask/marker_regression/plink_mapping.py b/wqflask/wqflask/marker_regression/plink_mapping.py
index 2f282adc..6c38c34f 100644
--- a/wqflask/wqflask/marker_regression/plink_mapping.py
+++ b/wqflask/wqflask/marker_regression/plink_mapping.py
@@ -83,7 +83,7 @@ def get_samples_from_ped_file(dataset):
     sample_list=[]
 
     while line:
-        lineList = string.split(string.strip(line), '\t')
+        lineList = line.strip().split('\t')
         lineList = list(map(string.strip, lineList))
 
         sample_name = lineList[0]
@@ -155,8 +155,8 @@ def parse_plink_output(output_filename, species):
 # output: lineList list
 #######################################################
 def build_line_list(line=None):
-    line_list = string.split(string.strip(line), ' ')# irregular number of whitespaces between columns
+    line_list = line.strip().split(' ')# irregular number of whitespaces between columns
     line_list = [item for item in line_list if item !='']
     line_list = list(map(string.strip, line_list))
 
-    return line_list
\ No newline at end of file
+    return line_list
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index e93b0289..88cd7dca 100644
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -229,8 +229,8 @@ class ShowTrait(object):
         hddn = OrderedDict()
 
         if self.dataset.group.allsamples:
-            hddn['allsamples'] = string.join(self.dataset.group.allsamples, ' ')
-        hddn['primary_samples'] = string.join(self.primary_sample_names, ',')
+            hddn['allsamples'] = ''.join(self.dataset.group.allsamples)
+        hddn['primary_samples'] = ''.join(self.primary_sample_names)
         hddn['trait_id'] = self.trait_id
         hddn['trait_display_name'] = self.this_trait.display_name
         hddn['dataset'] = self.dataset.name
diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py
index 0db7e1fe..2df71b12 100644
--- a/wqflask/wqflask/snp_browser/snp_browser.py
+++ b/wqflask/wqflask/snp_browser/snp_browser.py
@@ -456,7 +456,7 @@ class SnpBrowser(object):
 
                 function_list = []
                 if function_details:
-                    function_list = string.split(string.strip(function_details), ",")
+                    function_list = function_details.strip().split(",")
                     function_list = list(map(string.strip, function_list))
                     function_list[0] = function_list[0].title()
                     function_details = ", ".join(item for item in function_list)
@@ -722,11 +722,11 @@ def get_effect_details_by_category(effect_name = None, effect_value = None):
     new_codon_group_list = ['Start Gained']
     codon_effect_group_list = ['Start Lost', 'Stop Gained', 'Stop Lost', 'Nonsynonymous', 'Synonymous']
 
-    effect_detail_list = string.split(string.strip(effect_value), '|')
+    effect_detail_list = effect_value.strip().split('|')
     effect_detail_list = list(map(string.strip, effect_detail_list))
 
     for index, item in enumerate(effect_detail_list):
-        item_list = string.split(string.strip(item), ',')
+        item_list = item.strip().split(',')
         item_list = list(map(string.strip, item_list))
 
         gene_id = item_list[0]
@@ -746,13 +746,13 @@ def get_effect_details_by_category(effect_name = None, effect_value = None):
             if effect_name in new_codon_group_list:
                 new_codon = item_list[6]
                 tmp_list = [biotype, new_codon]
-                function_detail_list.append(string.join(tmp_list, ", "))
+                function_detail_list.append(", ".join(tmp_list))
             elif effect_name in codon_effect_group_list:
                 old_new_AA = item_list[6]
                 old_new_codon = item_list[7]
                 codon_num = item_list[8]
                 tmp_list = [biotype, old_new_AA, old_new_codon, codon_num]
-                function_detail_list.append(string.join(tmp_list, ", "))
+                function_detail_list.append(", ".join(tmp_list))
             else:
                 function_detail_list.append(biotype)
 
@@ -852,7 +852,7 @@ def get_gene_id_name_dict(species_id, gene_name_list):
     if len(gene_name_list) == 0:
         return ""
     gene_name_str_list = ["'" + gene_name + "'" for gene_name in gene_name_list]
-    gene_name_str = string.join(gene_name_str_list, ",")
+    gene_name_str = ",".join(gene_name_str_list)
 
     query = """
                 SELECT