Permalink
Browse files

BioSQL: Some more PEP8 whitespace cleanup.

  • Loading branch information...
1 parent ae8cc5a commit 0f6231c08a7f43459c26f703eda633de7930e326 @cbrueffer cbrueffer committed with peterjc Dec 11, 2012
Showing with 23 additions and 23 deletions.
  1. +5 −5 BioSQL/BioSeq.py
  2. +7 −7 BioSQL/BioSeqDatabase.py
  3. +3 −3 BioSQL/DBUtils.py
  4. +8 −8 BioSQL/Loader.py
View
@@ -38,7 +38,7 @@ def __init__(self, primary_id, adaptor, alphabet, start, length):
def __len__(self):
return self._length
- def __getitem__(self, index) : # Seq API requirement
+ def __getitem__(self, index): # Seq API requirement
#Note since Python 2.0, __getslice__ is deprecated
#and __getitem__ is used instead.
#See http://docs.python.org/ref/sequence-methods.html
@@ -252,7 +252,7 @@ def _retrieve_features(adaptor, primary_id):
import warnings
warnings.warn("Inverted location start/end (%i and %i) for "
"seqfeature_id %s" % (start, end, seqfeature_id))
- locations.append( (location_id, start, end, strand) )
+ locations.append((location_id, start, end, strand))
# Get possible remote reference information
remote_results = adaptor.execute_and_fetchall(
"SELECT location_id, dbname, accession, version"
@@ -270,7 +270,7 @@ def _retrieve_features(adaptor, primary_id):
dbname = None
lookup[location_id] = (dbname, v)
- feature = SeqFeature.SeqFeature(type = seqfeature_type)
+ feature = SeqFeature.SeqFeature(type=seqfeature_type)
feature._seqfeature_id = seqfeature_id # Store the key as a private property
feature.qualifiers = qualifiers
if len(locations) == 0:
@@ -321,7 +321,7 @@ def _retrieve_features(adaptor, primary_id):
if len(strands) == 1:
feature.strand = feature.sub_features[0].strand
else:
- feature.strand = None # i.e. mixed strands
+ feature.strand = None # i.e. mixed strands
seq_feature_list.append(feature)
@@ -359,7 +359,7 @@ def _retrieve_annotations(adaptor, primary_id, taxon_id):
def _make_unicode_into_string(text):
if isinstance(text, unicode):
return str(text)
- else :
+ else:
return text
View
@@ -16,10 +16,10 @@
import Loader
import DBUtils
-_POSTGRES_RULES_PRESENT = False # Hack for BioSQL Bug 2839
+_POSTGRES_RULES_PRESENT = False # Hack for BioSQL Bug 2839
-def open_database(driver = "MySQLdb", **kwargs):
+def open_database(driver="MySQLdb", **kwargs):
"""Main interface for loading a existing BioSQL-style database.
This function is the easiest way to retrieve a connection to a
@@ -229,11 +229,11 @@ def load_database_sql(self, sql_file):
sql_handle = open(sql_file, "rU")
sql = r""
for line in sql_handle:
- if line.startswith("--"): # don't include comment lines
+ if line.startswith("--"): # don't include comment lines
pass
- elif line.startswith("#"): # ditto for MySQL comments
+ elif line.startswith("#"): # ditto for MySQL comments
pass
- elif line.strip(): # only include non-blank lines
+ elif line.strip(): # only include non-blank lines
sql += line.strip()
sql += ' '
@@ -246,8 +246,8 @@ def load_database_sql(self, sql_file):
# 2. MySQL needs the database loading split up into single lines of
# SQL executed one at a time
elif self.module_name in ["MySQLdb", "sqlite3"]:
- sql_parts = sql.split(";") # one line per sql command
- for sql_line in sql_parts[:-1]: # don't use the last item, it's blank
+ sql_parts = sql.split(";") # one line per sql command
+ for sql_line in sql_parts[:-1]: # don't use the last item, it's blank
self.adaptor.cursor.execute(sql_line)
else:
raise ValueError("Module %s not supported by the loader." %
View
@@ -35,7 +35,7 @@ def execute(self, cursor, sql, args=None):
"""
cursor.execute(sql, args or ())
- def autocommit(self, conn, y = 1):
+ def autocommit(self, conn, y=1):
# Let's hope it was not really needed
pass
@@ -84,7 +84,7 @@ def last_id(self, cursor, table):
class Psycopg2_dbutils(_PostgreSQL_dbutils):
"""Custom database utilities for Psycopg2 (PostgreSQL)."""
- def autocommit(self, conn, y = True):
+ def autocommit(self, conn, y=True):
if y:
conn.set_isolation_level(0)
else:
@@ -95,7 +95,7 @@ def autocommit(self, conn, y = True):
class Pgdb_dbutils(_PostgreSQL_dbutils):
"""Custom database utilities for Pgdb (aka PyGreSQL, for PostgreSQL)."""
- def autocommit(self, conn, y = True):
+ def autocommit(self, conn, y=True):
raise NotImplementedError("pgdb does not support this!")
_dbutils["pgdb"] = Pgdb_dbutils
View
@@ -325,8 +325,8 @@ def add_space(letter):
return answer
def _get_taxon_id_from_ncbi_taxon_id(self, ncbi_taxon_id,
- scientific_name = None,
- common_name = None):
+ scientific_name=None,
+ common_name=None):
"""Get the taxon id for this record from the NCBI taxon ID (PRIVATE).
ncbi_taxon_id - string containing an NCBI taxon id
@@ -496,15 +496,15 @@ def _load_bioentry_table(self, record):
"""
# get the pertinent info and insert it
- if record.id.count(".") == 1: # try to get a version from the id
+ if record.id.count(".") == 1: # try to get a version from the id
#This assumes the string is something like "XXXXXXXX.123"
accession, version = record.id.split('.')
try:
version = int(version)
except ValueError:
accession = record.id
version = 0
- else: # otherwise just use a version of 0
+ else: # otherwise just use a version of 0
accession = record.id
version = 0
@@ -706,7 +706,7 @@ def _load_reference(self, reference, rank, bioentry_id):
crc = crc64("".join(s))
refs = self.adaptor.execute_and_fetch_col0(
"SELECT reference_id FROM reference"
- r" WHERE crc = %s", (crc,))
+ r" WHERE crc = %s", (crc,))
if not refs:
if reference.medline_id:
dbxref_id = self._add_dbxref("MEDLINE",
@@ -760,12 +760,12 @@ def _load_seqfeature_basic(self, feature_type, feature_rank, bioentry_id):
"""
ontology_id = self._get_ontology_id('SeqFeature Keys')
seqfeature_key_id = self._get_term_id(feature_type,
- ontology_id = ontology_id)
+ ontology_id=ontology_id)
# XXX source is always EMBL/GenBank/SwissProt here; it should depend on
# the record (how?)
source_cat_id = self._get_ontology_id('SeqFeature Sources')
source_term_id = self._get_term_id('EMBL/GenBank/SwissProt',
- ontology_id = source_cat_id)
+ ontology_id=source_cat_id)
sql = r"INSERT INTO seqfeature (bioentry_id, type_term_id, " \
r"source_term_id, rank) VALUES (%s, %s, %s, %s)"
@@ -801,7 +801,7 @@ def _load_seqfeature_locations(self, feature, seqfeature_id):
# two cases, a simple location or a split location
if not feature.sub_features: # simple location
self._insert_seqfeature_location(feature, 1, seqfeature_id)
- else: # split location
+ else: # split location
for rank, cur_feature in enumerate(feature.sub_features):
self._insert_seqfeature_location(cur_feature,
rank + 1,

0 comments on commit 0f6231c

Please sign in to comment.