about summary refs log tree commit diff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorBonfaceKilz2021-04-30 12:45:59 +0300
committerBonfaceKilz2021-04-30 13:45:15 +0300
commit03b6bcee689c1910bd850c6109cc37adc509cf5a (patch)
tree2ca686d7f1b6649bfbd593607aa406eff8efbfb7 /wqflask/utility
parent6be1111fd76a2c47de7a20cc18bb9f4d8d2d4ffa (diff)
downloadgenenetwork2-03b6bcee689c1910bd850c6109cc37adc509cf5a.tar.gz
autopep8: Fix E501
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/Plot.py9
-rw-r--r--wqflask/utility/benchmark.py9
-rw-r--r--wqflask/utility/corestats.py3
-rw-r--r--wqflask/utility/elasticsearch_tools.py6
-rw-r--r--wqflask/utility/gen_geno_ob.py12
-rw-r--r--wqflask/utility/genofile_parser.py3
-rw-r--r--wqflask/utility/logger.py3
-rw-r--r--wqflask/utility/redis_tools.py9
-rw-r--r--wqflask/utility/startup_config.py6
-rw-r--r--wqflask/utility/svg.py60
-rw-r--r--wqflask/utility/tools.py12
11 files changed, 88 insertions, 44 deletions
diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py
index d35b2089..4f5691c1 100644
--- a/wqflask/utility/Plot.py
+++ b/wqflask/utility/Plot.py
@@ -178,7 +178,8 @@ def plotBar(canvas, data, barColor=BLUE, axesColor=BLACK, labelColor=BLACK, XLab
 
     # draw drawing region
     im_drawer.rectangle(
-        xy=((xLeftOffset, yTopOffset), (xLeftOffset + plotWidth, yTopOffset + plotHeight))
+        xy=((xLeftOffset, yTopOffset),
+            (xLeftOffset + plotWidth, yTopOffset + plotHeight))
     )
 
     # draw scale
@@ -199,11 +200,13 @@ def plotBar(canvas, data, barColor=BLUE, axesColor=BLACK, labelColor=BLACK, XLab
     y = yLow
     for i in range(int(stepY) + 1):
        yc = yTopOffset + plotHeight - (y - yLow) * yScale
-       im_drawer.line(xy=((xLeftOffset, yc), (xLeftOffset - 5, yc)), fill=axesColor)
+       im_drawer.line(
+           xy=((xLeftOffset, yc), (xLeftOffset - 5, yc)), fill=axesColor)
        strY = "%d" % y
        im_drawer.text(
            text=strY,
-           xy=(xLeftOffset - im_drawer.textsize(strY, font=scaleFont)[0] - 6, yc + 5),
+           xy=(xLeftOffset - im_drawer.textsize(strY,
+               font=scaleFont)[0] - 6, yc + 5),
            font=scaleFont)
        y += (yTop - yLow) / stepY
 
diff --git a/wqflask/utility/benchmark.py b/wqflask/utility/benchmark.py
index 48ab1dc0..6ece2f21 100644
--- a/wqflask/utility/benchmark.py
+++ b/wqflask/utility/benchmark.py
@@ -19,7 +19,8 @@ class Bench:
             if self.name:
                 logger.debug("Starting benchmark: %s" % (self.name))
             else:
-                logger.debug("Starting benchmark at: %s [%i]" % (inspect.stack()[1][3], inspect.stack()[1][2]))
+                logger.debug("Starting benchmark at: %s [%i]" % (
+                    inspect.stack()[1][3], inspect.stack()[1][2]))
         self.start_time = time.time()
 
     def __exit__(self, type, value, traceback):
@@ -33,11 +34,13 @@ class Bench:
             logger.info("  %s took: %f seconds" % (name, (time_taken)))
 
         if self.name:
-            Bench.entries[self.name] = Bench.entries.get(self.name, 0) + time_taken
+            Bench.entries[self.name] = Bench.entries.get(
+                self.name, 0) + time_taken
 
     @classmethod
     def report(cls):
-        total_time = sum((time_taken for time_taken in list(cls.entries.values())))
+        total_time = sum(
+            (time_taken for time_taken in list(cls.entries.values())))
         print("\nTiming report\n")
         for name, time_taken in list(cls.entries.items()):
             percent = int(round((time_taken / total_time) * 100))
diff --git a/wqflask/utility/corestats.py b/wqflask/utility/corestats.py
index 523280a1..da0a21db 100644
--- a/wqflask/utility/corestats.py
+++ b/wqflask/utility/corestats.py
@@ -65,7 +65,8 @@ class Stats:
         if len(self.sequence) < 1:
             value = None
         elif (percentile >= 100):
-            sys.stderr.write('ERROR: percentile must be < 100.  you supplied: %s\n' % percentile)
+            sys.stderr.write(
+                'ERROR: percentile must be < 100.  you supplied: %s\n' % percentile)
             value = None
         else:
             element_idx = int(len(self.sequence) * (percentile / 100.0))
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py
index 9415cef0..55907dd5 100644
--- a/wqflask/utility/elasticsearch_tools.py
+++ b/wqflask/utility/elasticsearch_tools.py
@@ -49,7 +49,8 @@ from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT
 
 
 def test_elasticsearch_connection():
-    es = Elasticsearch(['http://' + ELASTICSEARCH_HOST + ":" + str(ELASTICSEARCH_PORT) + '/'], verify_certs=True)
+    es = Elasticsearch(['http://' + ELASTICSEARCH_HOST + \
+                       ":" + str(ELASTICSEARCH_PORT) + '/'], verify_certs=True)
     if not es.ping():
         logger.warning("Elasticsearch is DOWN")
 
@@ -88,7 +89,8 @@ def setup_users_index(es_connection):
                     "type": "keyword"}}}
 
         es_connection.indices.create(index='users', ignore=400)
-        es_connection.indices.put_mapping(body=index_settings, index="users", doc_type="local")
+        es_connection.indices.put_mapping(
+            body=index_settings, index="users", doc_type="local")
 
 
 def get_user_by_unique_column(es, column_name, column_value, index="users", doc_type="local"):
diff --git a/wqflask/utility/gen_geno_ob.py b/wqflask/utility/gen_geno_ob.py
index 24604e58..e619b7b6 100644
--- a/wqflask/utility/gen_geno_ob.py
+++ b/wqflask/utility/gen_geno_ob.py
@@ -38,13 +38,15 @@ class genotype:
 
     def read_rdata_output(self, qtl_results):
         # ZS: This is necessary because R/qtl requires centimorgan marker positions, which it normally gets from the .geno file, but that doesn't exist for HET3-ITP (which only has RData), so it needs to read in the marker cM positions from the results
-        self.chromosomes = []  # ZS: Overwriting since the .geno file's contents are just placeholders
+        # ZS: Overwriting since the .geno file's contents are just placeholders
+        self.chromosomes = []
 
         this_chr = ""  # ZS: This is so it can track when the chromosome changes as it iterates through markers
         chr_ob = None
         for marker in qtl_results:
             locus = Locus(self)
-            if (str(marker['chr']) != this_chr) and this_chr != "X":  # ZS: This is really awkward but works as a temporary fix
+            # ZS: This is really awkward but works as a temporary fix
+            if (str(marker['chr']) != this_chr) and this_chr != "X":
                 if this_chr != "":
                     self.chromosomes.append(chr_ob)
                 this_chr = str(marker['chr'])
@@ -156,9 +158,11 @@ class Locus:
             try:
                 self.cM = float(marker_row[geno_ob.cm_column])
             except:
-                self.cM = float(marker_row[geno_ob.mb_column]) if geno_ob.mb_exists else 0
+                self.cM = float(
+                    marker_row[geno_ob.mb_column]) if geno_ob.mb_exists else 0
             try:
-                self.Mb = float(marker_row[geno_ob.mb_column]) if geno_ob.mb_exists else None
+                self.Mb = float(
+                    marker_row[geno_ob.mb_column]) if geno_ob.mb_exists else None
             except:
                 self.Mb = self.cM
 
diff --git a/wqflask/utility/genofile_parser.py b/wqflask/utility/genofile_parser.py
index 94a08c17..09100bd9 100644
--- a/wqflask/utility/genofile_parser.py
+++ b/wqflask/utility/genofile_parser.py
@@ -92,7 +92,8 @@ class ConvertGenoFile:
         genotypes = row_items[2:]
       for item_count, genotype in enumerate(genotypes):
         if genotype.upper().strip() in self.configurations:
-          this_marker.genotypes.append(self.configurations[genotype.upper().strip()])
+          this_marker.genotypes.append(
+            self.configurations[genotype.upper().strip()])
         else:
           print("WARNING:", genotype.upper())
           this_marker.genotypes.append("NA")
diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py
index 47079818..d706e32a 100644
--- a/wqflask/utility/logger.py
+++ b/wqflask/utility/logger.py
@@ -151,5 +151,6 @@ def getLogger(name, level=None):
     else:
         logger.setLevel(LOG_LEVEL)
 
-    logger.info("Log level of " + name + " set to " + logging.getLevelName(logger.getEffectiveLevel()))
+    logger.info("Log level of " + name + " set to " + \
+                logging.getLevelName(logger.getEffectiveLevel()))
     return gnlogger
diff --git a/wqflask/utility/redis_tools.py b/wqflask/utility/redis_tools.py
index 8052035f..96a4be12 100644
--- a/wqflask/utility/redis_tools.py
+++ b/wqflask/utility/redis_tools.py
@@ -133,8 +133,10 @@ def get_user_groups(user_id):
     for key in groups_list:
         try:
             group_ob = json.loads(groups_list[key])
-            group_admins = set([this_admin.encode('utf-8') if this_admin else None for this_admin in group_ob['admins']])
-            group_members = set([this_member.encode('utf-8') if this_member else None for this_member in group_ob['members']])
+            group_admins = set([this_admin.encode(
+                'utf-8') if this_admin else None for this_admin in group_ob['admins']])
+            group_members = set([this_member.encode(
+                'utf-8') if this_member else None for this_member in group_ob['members']])
             if user_id in group_admins:
                 admin_group_ids.append(group_ob['id'])
             elif user_id in group_members:
@@ -203,7 +205,8 @@ def get_groups_like_unique_column(column_name, column_value):
                         if column_value in group_info[column_name]:
                             matched_groups.append(group_info)
         else:
-            matched_groups.append(load_json_from_redis(group_list, column_value))
+            matched_groups.append(
+                load_json_from_redis(group_list, column_value))
 
     return matched_groups
 
diff --git a/wqflask/utility/startup_config.py b/wqflask/utility/startup_config.py
index 92f944bc..05f8a2b0 100644
--- a/wqflask/utility/startup_config.py
+++ b/wqflask/utility/startup_config.py
@@ -28,7 +28,8 @@ def app_config():
     port = get_setting_int("SERVER_PORT")
 
     if get_setting_bool("USE_GN_SERVER"):
-        print(("GN2 API server URL is [" + BLUE + get_setting("GN_SERVER_URL") + ENDC + "]"))
+        print(
+            ("GN2 API server URL is [" + BLUE + get_setting("GN_SERVER_URL") + ENDC + "]"))
         import requests
         page = requests.get(get_setting("GN_SERVER_URL"))
         if page.status_code != 200:
@@ -37,4 +38,5 @@ def app_config():
     # import utility.elasticsearch_tools as es
     # es.test_elasticsearch_connection()
 
-    print(("GN2 is running. Visit %s[http://localhost:%s/%s](%s)" % (BLUE, str(port), ENDC, get_setting("WEBSERVER_URL"))))
+    print(("GN2 is running. Visit %s[http://localhost:%s/%s](%s)" %
+          (BLUE, str(port), ENDC, get_setting("WEBSERVER_URL"))))
diff --git a/wqflask/utility/svg.py b/wqflask/utility/svg.py
index f5ef81e1..8d2e13ab 100644
--- a/wqflask/utility/svg.py
+++ b/wqflask/utility/svg.py
@@ -239,19 +239,23 @@ class pathdata:
 
     def smbezier(self, x2, y2, x, y):
         """smooth bezier with xy2 to xy absolut"""
-        self.path.append('S' + str(x2) + ',' + str(y2) + ' ' + str(x) + ',' + str(y))
+        self.path.append('S' + str(x2) + ',' + str(y2) + \
+                         ' ' + str(x) + ',' + str(y))
 
     def relsmbezier(self, x2, y2, x, y):
         """smooth bezier with xy2 to xy relative"""
-        self.path.append('s' + str(x2) + ',' + str(y2) + ' ' + str(x) + ',' + str(y))
+        self.path.append('s' + str(x2) + ',' + str(y2) + \
+                         ' ' + str(x) + ',' + str(y))
 
     def qbezier(self, x1, y1, x, y):
         """quadratic bezier with xy1 to xy absolut"""
-        self.path.append('Q' + str(x1) + ',' + str(y1) + ' ' + str(x) + ',' + str(y))
+        self.path.append('Q' + str(x1) + ',' + str(y1) + \
+                         ' ' + str(x) + ',' + str(y))
 
     def relqbezier(self, x1, y1, x, y):
         """quadratic bezier with xy1 to xy relative"""
-        self.path.append('q' + str(x1) + ',' + str(y1) + ' ' + str(x) + ',' + str(y))
+        self.path.append('q' + str(x1) + ',' + str(y1) + \
+                         ' ' + str(x) + ',' + str(y))
 
     def smqbezier(self, x, y):
         """smooth quadratic bezier to xy absolut"""
@@ -447,7 +451,8 @@ class rect(SVGelement):
         if width == None or height == None:
             raise ValueError('both height and width are required')
 
-        SVGelement.__init__(self, 'rect', {'width': width, 'height': height}, **args)
+        SVGelement.__init__(
+            self, 'rect', {'width': width, 'height': height}, **args)
         if x != None:
             self.attributes['x'] = x
         if y != None:
@@ -545,7 +550,8 @@ class polyline(SVGelement):
     """
 
     def __init__(self, points, fill=None, stroke=None, stroke_width=None,**args):
-        SVGelement.__init__(self, 'polyline', {'points': _xypointlist(points)}, **args)
+        SVGelement.__init__(self, 'polyline', {
+                            'points': _xypointlist(points)}, **args)
         if fill != None:
             self.attributes['fill'] = fill
         if stroke_width != None:
@@ -561,7 +567,8 @@ class polygon(SVGelement):
     """
 
     def __init__(self, points, fill=None, stroke=None, stroke_width=None,**args):
-        SVGelement.__init__(self, 'polygon', {'points': _xypointlist(points)}, **args)
+        SVGelement.__init__(
+            self, 'polygon', {'points': _xypointlist(points)}, **args)
         if fill != None:
             self.attributes['fill'] = fill
         if stroke_width != None:
@@ -745,7 +752,8 @@ class image(SVGelement):
     def __init__(self, url, x=None, y=None, width=None,height=None,**args):
         if width == None or height == None:
             raise ValueError('both height and width are required')
-        SVGelement.__init__(self, 'image', {'xlink:href': url, 'width': width, 'height':height}, **args)
+        SVGelement.__init__(
+            self, 'image', {'xlink:href': url, 'width': width, 'height':height}, **args)
         if x != None:
             self.attributes['x'] = x
         if y != None:
@@ -886,7 +894,8 @@ class script(SVGelement):
     """
 
     def __init__(self, type, cdata=None, **args):
-        SVGelement.__init__(self, 'script', {'type': type}, cdata=cdata, **args)
+        SVGelement.__init__(
+            self, 'script', {'type': type}, cdata=cdata, **args)
 
 
 class animate(SVGelement):
@@ -896,7 +905,8 @@ class animate(SVGelement):
     """
 
     def __init__(self, attribute, fr=None, to=None, dur=None,**args):
-        SVGelement.__init__(self, 'animate', {'attributeName': attribute}, **args)
+        SVGelement.__init__(
+            self, 'animate', {'attributeName': attribute}, **args)
         if fr != None:
             self.attributes['from'] = fr
         if to != None:
@@ -926,7 +936,8 @@ class animateTransform(SVGelement):
     """
 
     def __init__(self, type=None, fr=None, to=None, dur=None,**args):
-        SVGelement.__init__(self, 'animateTransform', {'attributeName': 'transform'}, **args)
+        SVGelement.__init__(self, 'animateTransform', {
+                            'attributeName': 'transform'}, **args)
         # As far as I know the attributeName is always transform
         if type != None:
             self.attributes['type'] = type
@@ -945,7 +956,8 @@ class animateColor(SVGelement):
     """
 
     def __init__(self, attribute, type=None, fr=None, to=None,dur=None,**args):
-        SVGelement.__init__(self, 'animateColor', {'attributeName': attribute}, **args)
+        SVGelement.__init__(self, 'animateColor', {
+                            'attributeName': attribute}, **args)
         if type != None:
             self.attributes['type'] = type
         if fr != None:
@@ -1020,11 +1032,13 @@ class drawing:
             import io
             xml = io.StringIO()
             xml.write("<?xml version='1.0' encoding='UTF-8'?>\n")
-            xml.write("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"")
+            xml.write(
+                "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"")
             if self.entity:
                 xml.write(" [\n")
                 for item in list(self.entity.keys()):
-                    xml.write("<!ENTITY %s \"%s\">\n" % (item, self.entity[item]))
+                    xml.write("<!ENTITY %s \"%s\">\n" %
+                              (item, self.entity[item]))
                 xml.write("]")
             xml.write(">\n")
             self.svg.toXml(0, xml)
@@ -1042,7 +1056,8 @@ class drawing:
             else:
                 if filename[-4:] == 'svgz':
                     import gzip
-                    f = gzip.GzipFile(filename=filename, mode="wb", compresslevel=9)
+                    f = gzip.GzipFile(filename=filename,
+                                      mode="wb", compresslevel=9)
                     f.write(xml.getvalue())
                     f.close()
                 else:
@@ -1057,7 +1072,8 @@ class drawing:
             writes a svg drawing to the screen or to a file
             compresses if filename ends with svgz or if compress is true
             """
-            doctype = implementation.createDocumentType('svg', "-//W3C//DTD SVG 1.0//EN""", 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd ')
+            doctype = implementation.createDocumentType(
+                'svg', "-//W3C//DTD SVG 1.0//EN""", 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd ')
 
             global root
             # root is defined global so it can be used by the appender. Its also possible to use it as an arugument but
@@ -1076,8 +1092,10 @@ class drawing:
                 if element.text:
                     textnode = root.createTextNode(element.text)
                     e.appendChild(textnode)
-                for attribute in list(element.attributes.keys()):  # in element.attributes is supported from python 2.2
-                    e.setAttribute(attribute, str(element.attributes[attribute]))
+                # in element.attributes is supported from python 2.2
+                for attribute in list(element.attributes.keys()):
+                    e.setAttribute(attribute, str(
+                        element.attributes[attribute]))
                 if element.elements:
                     for el in element.elements:
                         e = appender(el, e)
@@ -1105,7 +1123,8 @@ class drawing:
                         import io
                         xml = io.StringIO()
                         PrettyPrint(root, xml)
-                        f = gzip.GzipFile(filename=filename, mode='wb', compresslevel=9)
+                        f = gzip.GzipFile(filename=filename,
+                                          mode='wb', compresslevel=9)
                         f.write(xml.getvalue())
                         f.close()
                     else:
@@ -1119,7 +1138,8 @@ class drawing:
         try:
             import xml.parsers.xmlproc.xmlval
         except:
-            raise exceptions.ImportError('PyXml is required for validating SVG')
+            raise exceptions.ImportError(
+                'PyXml is required for validating SVG')
         svg = self.toXml()
         xv = xml.parsers.xmlproc.xmlval.XMLValidator()
         try:
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index 4fe4db08..263c3948 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -64,7 +64,8 @@ def get_setting(command_id, guess=None):
                 command = value(guess)
                 if command is None or command == "":
                     # print command
-                    raise Exception(command_id + ' setting unknown or faulty (update default_settings.py?).')
+                    raise Exception(
+                        command_id + ' setting unknown or faulty (update default_settings.py?).')
     # print("Set "+command_id+"="+str(command))
     return command
 
@@ -113,7 +114,8 @@ def js_path(module=None):
     try_guix = get_setting("JS_GUIX_PATH") + "/" + module
     if valid_path(try_guix):
         return try_guix
-    raise "No JS path found for " + module + " (if not in Guix check JS_GN_PATH)"
+    raise "No JS path found for " + module + \
+        " (if not in Guix check JS_GN_PATH)"
 
 
 def reaper_command(guess=None):
@@ -292,7 +294,8 @@ ORCID_CLIENT_SECRET = get_setting('ORCID_CLIENT_SECRET')
 ORCID_AUTH_URL = None
 if ORCID_CLIENT_ID != 'UNKNOWN' and ORCID_CLIENT_SECRET:
     ORCID_AUTH_URL = "https://orcid.org/oauth/authorize?response_type=code&scope=/authenticate&show_login=true&client_id=" + \
-                      ORCID_CLIENT_ID + "&client_secret=" + ORCID_CLIENT_SECRET + "&redirect_uri=" + GN2_BRANCH_URL + "n/login/orcid_oauth2"
+                      ORCID_CLIENT_ID + "&client_secret=" + ORCID_CLIENT_SECRET + \
+                          "&redirect_uri=" + GN2_BRANCH_URL + "n/login/orcid_oauth2"
     ORCID_TOKEN_URL = get_setting('ORCID_TOKEN_URL')
 
 ELASTICSEARCH_HOST = get_setting('ELASTICSEARCH_HOST')
@@ -320,7 +323,8 @@ assert_dir(JS_GUIX_PATH + '/cytoscape-panzoom')
 CSS_PATH = JS_GUIX_PATH  # The CSS is bundled together with the JS
 # assert_dir(JS_PATH)
 
-JS_TWITTER_POST_FETCHER_PATH = get_setting("JS_TWITTER_POST_FETCHER_PATH", js_path("javascript-twitter-post-fetcher"))
+JS_TWITTER_POST_FETCHER_PATH = get_setting(
+    "JS_TWITTER_POST_FETCHER_PATH", js_path("javascript-twitter-post-fetcher"))
 assert_dir(JS_TWITTER_POST_FETCHER_PATH)
 assert_file(JS_TWITTER_POST_FETCHER_PATH + "/js/twitterFetcher_min.js")