Permalink
Browse files

Trim EOL whitespace (PEP8 W291, W293), batch 3.

  • Loading branch information...
1 parent 3194062 commit b1c859788edc2dafc5bbc50ff3c38670b1f84dcf @cbrueffer cbrueffer committed Dec 4, 2012
Showing with 756 additions and 811 deletions.
  1. +9 −9 BioSQL/BioSeq.py
  2. +37 −37 BioSQL/BioSeqDatabase.py
  3. +3 −3 BioSQL/DBUtils.py
  4. +27 −28 BioSQL/Loader.py
  5. +2 −2 Doc/examples/Proux_et_al_2002_Figure_6.py
  6. +1 −1 Doc/examples/fasta_iterator.py
  7. +15 −16 Doc/examples/getgene.py
  8. +2 −2 Doc/examples/local_blast.py
  9. +10 −10 Doc/examples/nmr/simplepredict.py
  10. +4 −4 Scripts/GenBank/check_output.py
  11. +1 −1 Scripts/GenBank/check_output_simple.py
  12. +3 −3 Scripts/GenBank/find_parser_problems.py
  13. +2 −4 Scripts/PDB/generate_three_to_one_dict.py
  14. +1 −1 Scripts/Performance/biosql_performance_load.py
  15. +2 −2 Scripts/Performance/biosql_performance_read.py
  16. +1 −1 Scripts/Restriction/ranacompiler.py
  17. +2 −3 Scripts/Restriction/rebase_update.py
  18. +2 −2 Scripts/SeqGui/SeqGui.py
  19. +4 −4 Scripts/debug/debug_blast_parser.py
  20. +9 −9 Scripts/scop_pdb.py
  21. +11 −12 Scripts/xbbtools/nextorf.py
  22. +8 −12 Scripts/xbbtools/xbb_blast.py
  23. +8 −9 Scripts/xbbtools/xbb_blastbg.py
  24. +0 −1 Scripts/xbbtools/xbb_help.py
  25. +14 −21 Scripts/xbbtools/xbb_search.py
  26. +9 −10 Scripts/xbbtools/xbb_translations.py
  27. +2 −3 Scripts/xbbtools/xbb_utils.py
  28. +35 −40 Scripts/xbbtools/xbb_widget.py
  29. +2 −2 Tests/requires_internet.py
  30. +1 −1 Tests/run_tests.py
  31. +18 −18 Tests/seq_tests_common.py
  32. +6 −6 Tests/test_Ace.py
  33. +1 −2 Tests/test_CAPS.py
  34. +1 −1 Tests/test_Chi2.py
  35. +1 −1 Tests/test_ClustalOmega_tool.py
  36. +34 −35 Tests/test_Cluster.py
  37. +5 −5 Tests/test_ColorSpiral.py
  38. +6 −6 Tests/test_Compass.py
  39. +2 −2 Tests/test_Dialign_tool.py
  40. +16 −17 Tests/test_Emboss.py
  41. +5 −5 Tests/test_EmbossPhylipNew.py
  42. +4 −4 Tests/test_Entrez.py
  43. +1 −1 Tests/test_FSSP.py
  44. +26 −26 Tests/test_GACrossover.py
  45. +3 −3 Tests/test_GAMutation.py
  46. +1 −2 Tests/test_GAOrganism.py
  47. +9 −9 Tests/test_GAQueens.py
  48. +1 −2 Tests/test_GARepair.py
  49. +3 −3 Tests/test_GASelection.py
  50. +10 −10 Tests/test_GenBank.py
  51. +22 −23 Tests/test_GenomeDiagram.py
  52. +3 −3 Tests/test_GraphicsBitmaps.py
  53. +12 −12 Tests/test_GraphicsChromosome.py
  54. +2 −2 Tests/test_GraphicsDistribution.py
  55. +1 −1 Tests/test_GraphicsGeneral.py
  56. +1 −1 Tests/test_HMMCasino.py
  57. +7 −7 Tests/test_HMMGeneral.py
  58. +1 −1 Tests/test_MMCIF.py
  59. +6 −6 Tests/test_Motif.py
  60. +1 −1 Tests/test_Muscle_tool.py
  61. +6 −6 Tests/test_NCBITextParser.py
  62. +1 −1 Tests/test_NCBIXML.py
  63. +8 −8 Tests/test_NCBI_BLAST_tools.py
  64. +1 −1 Tests/test_NCBI_qblast.py
  65. +1 −1 Tests/test_NNExclusiveOr.py
  66. +12 −13 Tests/test_NNGene.py
  67. +2 −2 Tests/test_NNGeneral.py
  68. +11 −11 Tests/test_Nexus.py
  69. +33 −33 Tests/test_PAML_baseml.py
  70. +22 −22 Tests/test_PAML_yn00.py
  71. +10 −10 Tests/test_PDB.py
  72. +2 −2 Tests/test_PDB_KDTree.py
  73. +2 −3 Tests/test_ParserSupport.py
  74. +3 −3 Tests/test_Pathway.py
  75. +2 −2 Tests/test_Phd.py
  76. +1 −1 Tests/test_PhyloXML.py
  77. +1 −1 Tests/test_PopGen_GenePop.py
  78. +2 −2 Tests/test_Prank_tool.py
  79. +1 −1 Tests/test_Probcons_tool.py
  80. +2 −10 Tests/test_SCOP_Astral.py
  81. +5 −5 Tests/test_SCOP_Cla.py
  82. +4 −4 Tests/test_SCOP_Des.py
  83. +4 −4 Tests/test_SCOP_Dom.py
  84. +3 −3 Tests/test_SCOP_Hie.py
  85. +4 −5 Tests/test_SCOP_Raf.py
  86. +0 −1 Tests/test_SCOP_Residues.py
  87. +6 −11 Tests/test_SCOP_Scop.py
  88. +14 −14 Tests/test_SearchIO_blast_xml.py
  89. +9 −9 Tests/test_SearchIO_hmmer3_text.py
  90. +1 −1 Tests/test_SearchIO_index.py
  91. +13 −13 Tests/test_SeqIO_AbiIO.py
  92. +1 −1 Tests/test_SeqIO_PdbIO.py
  93. +10 −10 Tests/test_SeqIO_QualityIO.py
  94. +30 −31 Tests/test_SeqIO_SeqXML.py
  95. +1 −1 Tests/test_SeqIO_convert.py
  96. +30 −31 Tests/test_SeqIO_features.py
  97. +2 −2 Tests/test_SeqIO_index.py
  98. +2 −2 Tests/test_SeqIO_online.py
  99. +2 −2 Tests/test_SeqRecord.py
  100. +1 −1 Tests/test_SeqUtils.py
  101. +7 −7 Tests/test_Seq_objs.py
  102. +16 −16 Tests/test_SwissProt.py
  103. +3 −3 Tests/test_TogoWS.py
  104. +2 −2 Tests/test_Tutorial.py
  105. +5 −5 Tests/test_Uniprot.py
  106. +1 −1 Tests/test_Wise.py
  107. +1 −1 Tests/test_XXmotif_tool.py
  108. +1 −1 Tests/test_align.py
  109. +2 −2 Tests/test_prodoc.py
  110. +1 −1 Tests/test_psw.py
  111. +0 −1 Tests/test_raxml_tool.py
  112. +13 −15 Tests/test_seq.py
  113. +1 −2 do2to3.py
  114. +2 −2 setup.py
View
18 BioSQL/BioSeq.py
@@ -36,7 +36,7 @@ def __init__(self, primary_id, adaptor, alphabet, start, length):
def __len__(self):
return self._length
-
+
def __getitem__(self, index) : # Seq API requirement
#Note since Python 2.0, __getslice__ is deprecated
#and __getitem__ is used instead.
@@ -49,7 +49,7 @@ def __getitem__(self, index) : # Seq API requirement
raise IndexError(i)
i = i + self._length
elif i >= self._length:
- raise IndexError(i)
+ raise IndexError(i)
return self.adaptor.get_subseq_as_string(self.primary_id,
self.start + i,
self.start + i + 1)
@@ -96,7 +96,7 @@ def __getitem__(self, index) : # Seq API requirement
self.start + i,
self.start + j)
return Seq(full[::index.step], self.alphabet)
-
+
def tostring(self):
"""Returns the full sequence as a python string.
@@ -138,7 +138,7 @@ def _retrieve_seq(adaptor, primary_id):
"SELECT alphabet, length, length(seq) FROM biosequence" \
" WHERE bioentry_id = %s", (primary_id,))
if not seqs : return
- assert len(seqs) == 1
+ assert len(seqs) == 1
moltype, given_length, length = seqs[0]
try:
@@ -158,7 +158,7 @@ def _retrieve_seq(adaptor, primary_id):
have_seq = False
del seq
del given_length
-
+
moltype = moltype.lower() #might be upper case in database
#We have no way of knowing if these sequences will use IUPAC
#alphabets, and we certainly can't assume they are unambiguous!
@@ -264,7 +264,7 @@ def _retrieve_features(adaptor, primary_id):
if dbname == "":
dbname = None
lookup[location_id] = (dbname, v)
-
+
feature = SeqFeature.SeqFeature(type = seqfeature_type)
feature._seqfeature_id = seqfeature_id #Store the key as a private property
feature.qualifiers = qualifiers
@@ -327,7 +327,7 @@ def _retrieve_location_qualifier_value(adaptor, location_id):
"SELECT value FROM location_qualifier_value" \
" WHERE location_id = %s", (location_id,))
try:
- return value[0]
+ return value[0]
except IndexError:
return ""
@@ -371,7 +371,7 @@ def _retrieve_qualifier_value(adaptor, primary_id):
def _retrieve_reference(adaptor, primary_id):
# XXX dbxref_qualifier_value
-
+
refs = adaptor.execute_and_fetchall(
"SELECT start_pos, end_pos, " \
" location, title, authors," \
@@ -427,7 +427,7 @@ def _retrieve_taxon(adaptor, primary_id, taxon_id):
#relies on the taxon table's parent_taxon_id field only (ignoring the
#optional left/right values). This means that it has to make a
#separate SQL query for each entry in the lineage, but it does still
- #appear to be *much* faster. See Bug 2494.
+ #appear to be *much* faster. See Bug 2494.
taxonomy = []
while taxon_id:
name, rank, parent_taxon_id = adaptor.execute_one(
View
74 BioSQL/BioSeqDatabase.py
@@ -23,7 +23,7 @@ def open_database(driver = "MySQLdb", **kwargs):
This function is the easiest way to retrieve a connection to a
database, doing something like:
-
+
>>> from BioSeq import BioSeqDatabase
>>> server = BioSeqDatabase.open_database(user="root", db="minidb")
@@ -105,7 +105,7 @@ def open_database(driver = "MySQLdb", **kwargs):
class DBServer:
"""Represents a BioSQL database continaing namespaces (sub-databases).
-
+
This acts like a Python dictionary, giving access to each namespace
(defined by a row in the biodatabase table) as a BioSeqDatabase object.
"""
@@ -115,7 +115,7 @@ def __init__(self, conn, module, module_name=None):
module_name = module.__name__
self.adaptor = Adaptor(conn, DBUtils.get_dbutils(module_name))
self.module_name = module_name
-
+
def __repr__(self):
return self.__class__.__name__ + "(%r)" % self.adaptor.conn
@@ -131,35 +131,35 @@ def __contains__(self, value):
"""Check if a namespace (sub-database) in this database."""
sql = "SELECT COUNT(name) FROM biodatabase WHERE name=%s;"
return bool(self.adaptor.execute_and_fetch_col0(sql, (value,))[0])
-
+
def __iter__(self):
"""Iterate over namespaces (sub-databases) in the database."""
#TODO - Iterate over the cursor, much more efficient
- return iter(self.adaptor.list_biodatabase_names())
+ return iter(self.adaptor.list_biodatabase_names())
if hasattr(dict, "iteritems"):
- #Python 2, use iteritems etc
+ #Python 2, use iteritems etc
def keys(self):
"""List of namespaces (sub-databases) in the database."""
return self.adaptor.list_biodatabase_names()
def values(self):
"""List of BioSeqDatabase objects in the database."""
return [self[key] for key in self.keys()]
-
+
def items(self):
"""List of (namespace, BioSeqDatabase) for entries in the database."""
return [(key, self[key]) for key in self.keys()]
-
+
def iterkeys(self):
"""Iterate over namespaces (sub-databases) in the database."""
return iter(self)
-
+
def itervalues(self):
"""Iterate over BioSeqDatabase objects in the database."""
for key in self:
yield self[key]
-
+
def iteritems(self):
"""Iterate over (namespace, BioSeqDatabase) in the database."""
for key in self:
@@ -169,12 +169,12 @@ def iteritems(self):
def keys(self):
"""Iterate over namespaces (sub-databases) in the database."""
return iter(self)
-
+
def values(self):
"""Iterate over BioSeqDatabase objects in the database."""
for key in self:
yield self[key]
-
+
def items(self):
"""Iterate over (namespace, BioSeqDatabase) in the database."""
for key in self:
@@ -188,13 +188,13 @@ def __delitem__(self, name):
def remove_database(self, db_name):
"""Remove a namespace and all its entries (OBSOLETE).
-
+
Try to remove all references to items in a database.
-
+
server.remove_database(name)
-
+
In keeping with the dictionary interface, you can now do this:
-
+
del server[name]
"""
import warnings
@@ -208,7 +208,7 @@ def new_database(self, db_name, authority=None, description=None):
"""
# make the database
sql = r"INSERT INTO biodatabase (name, authority, description)" \
- r" VALUES (%s, %s, %s)"
+ r" VALUES (%s, %s, %s)"
self.adaptor.execute(sql, (db_name, authority, description))
return BioSeqDatabase(self.adaptor, db_name)
@@ -234,7 +234,7 @@ def load_database_sql(self, sql_file):
elif line.strip(): # only include non-blank lines
sql += line.strip()
sql += ' '
-
+
# two ways to load the SQL
# 1. PostgreSQL can load it all at once and actually needs to
# due to FUNCTION defines at the end of the SQL which mess up
@@ -387,7 +387,7 @@ def list_bioentry_display_ids(self, dbid):
def list_any_ids(self, sql, args):
"""Return ids given a SQL statement to select for them.
-
+
This assumes that the given SQL does a SELECT statement that
returns a list of items. This parses them out of the 2D list
they come as and just returns them in a list.
@@ -413,7 +413,7 @@ def get_subseq_as_string(self, seqid, start, end):
# """select SUBSTRING(seq FROM %s FOR %s)
# from biosequence where bioentry_id = %s""",
# (start+1, length, seqid))[0]
- #
+ #
# Convert to a string on returning for databases that give back
# unicode. Shouldn't need unicode for sequences so this seems safe.
return str(self.execute_one(
@@ -441,7 +441,7 @@ def execute_and_fetchall(self, sql, args=None):
class BioSeqDatabase:
"""Represents a namespace (sub-database) within the BioSQL database.
-
+
i.e. One row in the biodatabase table, and all all rows in the bioentry
table associated with it.
"""
@@ -452,12 +452,12 @@ def __init__(self, adaptor, name):
def __repr__(self):
return "BioSeqDatabase(%r, %r)" % (self.adaptor, self.name)
-
+
def get_Seq_by_id(self, name):
"""Gets a DBSeqRecord object by its name
Example: seq_rec = db.get_Seq_by_id('ROA1_HUMAN')
-
+
The name of this method is misleading since it returns a DBSeqRecord
rather than a DBSeq ojbect, and presumably was to mirror BioPerl.
"""
@@ -504,7 +504,7 @@ def get_all_primary_ids(self):
These maybe ids (display style) or accession numbers or
something else completely different - they *are not*
meaningful outside of this database implementation.
-
+
Please use .keys() instead of .get_all_primary_ids()
"""
import warnings
@@ -543,35 +543,35 @@ def __contains__(self, value):
return False
return bool(self.adaptor.execute_and_fetch_col0(sql,
(self.dbid, bioentry_id))[0])
-
+
def __iter__(self):
"""Iterate over ids (which may not be meaningful outside this database)."""
#TODO - Iterate over the cursor, much more efficient
- return iter(self.adaptor.list_bioentry_ids(self.dbid))
+ return iter(self.adaptor.list_bioentry_ids(self.dbid))
if hasattr(dict, "iteritems"):
- #Python 2, use iteritems etc
+ #Python 2, use iteritems etc
def keys(self):
"""List of ids which may not be meaningful outside this database."""
return self.adaptor.list_bioentry_ids(self.dbid)
def values(self):
"""List of DBSeqRecord objects in the namespace (sub database)."""
return [self[key] for key in self.keys()]
-
+
def items(self):
"""List of (id, DBSeqRecord) for the namespace (sub database)."""
return [(key, self[key]) for key in self.keys()]
-
+
def iterkeys(self):
"""Iterate over ids (which may not be meaningful outside this database)."""
return iter(self)
-
+
def itervalues(self):
"""Iterate over DBSeqRecord objects in the namespace (sub database)."""
for key in self:
yield self[key]
-
+
def iteritems(self):
"""Iterate over (id, DBSeqRecord) for the namespace (sub database)."""
for key in self:
@@ -581,12 +581,12 @@ def iteritems(self):
def keys(self):
"""Iterate over ids (which may not be meaningful outside this database)."""
return iter(self)
-
+
def values(self):
"""Iterate over DBSeqRecord objects in the namespace (sub database)."""
for key in self:
yield self[key]
-
+
def items(self):
"""Iterate over (id, DBSeqRecord) for the namespace (sub database)."""
for key in self:
@@ -603,12 +603,12 @@ def lookup(self, **kwargs):
lookup_func = getattr(self.adaptor, lookup_name)
seqid = lookup_func(self.dbid, v)
return BioSeq.DBSeqRecord(self.adaptor, seqid)
-
+
def get_Seq_by_primary_id(self, seqid):
"""Get a DBSeqRecord by the primary (internal) id (OBSOLETE).
-
+
Rather than db.get_Seq_by_primary_id(my_id) use db[my_id]
-
+
The name of this method is misleading since it returns a DBSeqRecord
rather than a DBSeq ojbect, and presumably was to mirror BioPerl.
"""
@@ -663,7 +663,7 @@ def load(self, record_iterator, fetch_NCBI_taxonomy=False):
"'%s' AND version = '%s' AND biodatabase_id = '%s')"
self.adaptor.execute(sql % (gi, self.dbid, accession, version, self.dbid))
if self.adaptor.cursor.fetchone():
- raise self.adaptor.conn.IntegrityError("Duplicate record "
+ raise self.adaptor.conn.IntegrityError("Duplicate record "
"detected: record has not been inserted")
#End of hack
db_loader.load_seqrecord(cur_record)
View
6 BioSQL/DBUtils.py
@@ -26,7 +26,7 @@ def last_id(self, cursor, table):
cursor.execute(sql)
rv = cursor.fetchone()
return rv[0]
-
+
def execute(self, cursor, sql, args=None):
"""Just execute an sql command.
"""
@@ -58,7 +58,7 @@ def last_id(self, cursor, table):
#Google suggests this is the new way,
#same fix also suggested by Eric Gibert:
return cursor.lastrowid
-
+
_dbutils["MySQLdb"] = Mysql_dbutils
@@ -70,7 +70,7 @@ def next_id(self, cursor, table):
cursor.execute(sql)
rv = cursor.fetchone()
return rv[0]
-
+
def last_id(self, cursor, table):
table = self.tname(table)
sql = r"select currval('%s_pk_seq')" % table
View
55 BioSQL/Loader.py
@@ -45,7 +45,7 @@ def __init__(self, adaptor, dbid, fetch_NCBI_taxonomy=False):
self.adaptor = adaptor
self.dbid = dbid
self.fetch_NCBI_taxonomy = fetch_NCBI_taxonomy
-
+
def load_seqrecord(self, record):
"""Load a Biopython SeqRecord into the database.
"""
@@ -81,7 +81,6 @@ def _get_ontology_id(self, name, definition=None):
(name, definition))
return self.adaptor.last_id("ontology")
-
def _get_term_id(self,
name,
ontology_id=None,
@@ -107,7 +106,7 @@ def _get_term_id(self,
id_results = self.adaptor.execute_and_fetchall(sql, fields)
# something is wrong
if len(id_results) > 1:
- raise ValueError("Multiple term ids for %s: %r" %
+ raise ValueError("Multiple term ids for %s: %r" %
(name, id_results))
elif len(id_results) == 1:
return id_results[0][0]
@@ -135,7 +134,7 @@ def _get_taxon_id(self, record):
This searches the taxon/taxon_name tables using the
NCBI taxon ID, scientific name and common name to find
the matching taxon table entry's id.
-
+
If the species isn't in the taxon table, and we have at
least the NCBI taxon ID, scientific name or common name,
at least a minimal stub entry is created in the table.
@@ -148,7 +147,7 @@ def _get_taxon_id(self, record):
will populate and update the taxon/taxon_name tables
with the latest information from the NCBI.
"""
-
+
# To find the NCBI taxid, first check for a top level annotation
ncbi_taxon_id = None
if "ncbi_taxid" in record.annotations:
@@ -190,7 +189,7 @@ def _get_taxon_id(self, record):
return self._get_taxon_id_from_ncbi_taxon_id(ncbi_taxon_id,
scientific_name,
common_name)
-
+
if not common_name and not scientific_name:
# Nothing to go on... and there is no point adding
# a new entry to the database. We'll just leave this
@@ -250,13 +249,13 @@ def _get_taxon_id(self, record):
lineage.append([None, "varietas",
record.annotations["variant"]])
lineage[-1][0] = ncbi_taxon_id
-
+
left_value = self.adaptor.execute_one(
"SELECT MAX(left_value) FROM taxon")[0]
if not left_value:
left_value = 0
left_value += 1
-
+
# XXX -- Brad: Fixing this for now in an ugly way because
# I am getting overlaps for right_values. I need to dig into this
# more to actually understand how it works. I'm not sure it is
@@ -299,7 +298,7 @@ def _fix_name_class(self, entrez_name):
We need to make this conversion to match the taxon_name.name_class
values used by the BioSQL load_ncbi_taxonomy.pl script.
-
+
e.g.
"ScientificName" -> "scientific name",
"EquivalentName" -> "equivalent name",
@@ -332,10 +331,10 @@ def _get_taxon_id_from_ncbi_taxon_id(self, ncbi_taxon_id,
ncbi_taxon_id - string containing an NCBI taxon id
scientific_name - string, used if a stub entry is recorded
common_name - string, used if a stub entry is recorded
-
+
This searches the taxon table using ONLY the NCBI taxon ID
to find the matching taxon table entry's ID (database key).
-
+
If the species isn't in the taxon table, and the fetch_NCBI_taxonomy
flag is true, Biopython will attempt to go online using Bio.Entrez
to fetch the official NCBI lineage, recursing up the tree until an
@@ -372,7 +371,7 @@ def _get_taxon_id_from_ncbi_taxon_id(self, ncbi_taxon_id,
species_names.append(("scientific name", scientific_name))
if common_name:
species_names.append(("common name", common_name))
-
+
if self.fetch_NCBI_taxonomy:
#Go online to get the parent taxon ID!
handle = Entrez.efetch(db="taxonomy", id=ncbi_taxon_id, retmode="XML")
@@ -430,8 +429,8 @@ def _get_taxon_id_from_ncbi_taxon_id(self, ncbi_taxon_id,
for name_class, name in species_names:
self.adaptor.execute(
"INSERT INTO taxon_name(taxon_id, name, name_class)" \
- " VALUES (%s, %s, %s)", (taxon_id,
- name[:255],
+ " VALUES (%s, %s, %s)", (taxon_id,
+ name[:255],
name_class))
return taxon_id
@@ -485,7 +484,7 @@ def _get_taxon_id_from_ncbi_lineage(self, taxonomic_lineage):
if scientific_name:
self.adaptor.execute(
"INSERT INTO taxon_name(taxon_id, name, name_class)" \
- " VALUES (%s, %s, 'scientific name')", (taxon_id,
+ " VALUES (%s, %s, 'scientific name')", (taxon_id,
scientific_name[:255]))
return taxon_id
@@ -496,7 +495,7 @@ def _load_bioentry_table(self, record):
record - SeqRecord object to add to the database.
"""
# get the pertinent info and insert it
-
+
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('.')
@@ -528,7 +527,7 @@ def _load_bioentry_table(self, record):
#Allow description and division to default to NULL as in BioPerl.
description = getattr(record, 'description', None)
division = record.annotations.get("data_file_division", None)
-
+
sql = """
INSERT INTO bioentry (
biodatabase_id,
@@ -552,7 +551,7 @@ def _load_bioentry_table(self, record):
# division, description, version
self.adaptor.execute(sql, (self.dbid,
taxon_id,
- record.name,
+ record.name,
accession,
identifier,
division,
@@ -578,7 +577,7 @@ def _load_bioentry_date(self, record, bioentry_id):
date_id = self._get_term_id("date_changed", annotation_tags_id)
sql = r"INSERT INTO bioentry_qualifier_value" \
r" (bioentry_id, term_id, value, rank)" \
- r" VALUES (%s, %s, %s, 1)"
+ r" VALUES (%s, %s, %s, 1)"
self.adaptor.execute(sql, (bioentry_id, date_id, date))
def _load_biosequence(self, record, bioentry_id):
@@ -591,7 +590,7 @@ def _load_biosequence(self, record, bioentry_id):
#The biosequence table entry is optional, so if we haven't
#got a sequence, we don't need to write to the table.
return
-
+
# determine the string representation of the alphabet
if isinstance(record.seq.alphabet, Alphabet.DNAAlphabet):
alphabet = "dna"
@@ -635,7 +634,7 @@ def _load_comment(self, record, bioentry_id):
sql = "INSERT INTO comment (bioentry_id, comment_text, rank)" \
" VALUES (%s, %s, %s)"
self.adaptor.execute(sql, (bioentry_id, comment, index+1))
-
+
def _load_annotations(self, record, bioentry_id):
"""Record a SeqRecord's misc annotations in the database (PRIVATE).
@@ -738,13 +737,13 @@ def _load_reference(self, reference, rank, bioentry_id):
else:
start = None
end = None
-
+
sql = "INSERT INTO bioentry_reference (bioentry_id, reference_id," \
" start_pos, end_pos, rank)" \
" VALUES (%s, %s, %s, %s, %s)"
self.adaptor.execute(sql, (bioentry_id, reference_id,
start, end, rank + 1))
-
+
def _load_seqfeature(self, feature, feature_rank, bioentry_id):
"""Load a biopython SeqFeature into the database (PRIVATE).
"""
@@ -767,7 +766,7 @@ def _load_seqfeature_basic(self, feature_type, feature_rank, bioentry_id):
source_cat_id = self._get_ontology_id('SeqFeature Sources')
source_term_id = self._get_term_id('EMBL/GenBank/SwissProt',
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)"
self.adaptor.execute(sql, (bioentry_id, seqfeature_key_id,
@@ -798,7 +797,7 @@ def _load_seqfeature_locations(self, feature, seqfeature_id):
import warnings
warnings.warn("%s location operators are not fully supported" \
% feature.location_operator)
-
+
# two cases, a simple location or a split location
if not feature.sub_features: # simple location
self._insert_seqfeature_location(feature, 1, seqfeature_id)
@@ -833,7 +832,7 @@ def _insert_seqfeature_location(self, feature, rank, seqfeature_id):
if feature.ref:
# sub_feature remote locations when they are in the same db as the current
# record do not have a value for ref_db, which the SeqFeature object
- # stores as None. BioSQL schema requires a varchar and is not NULL
+ # stores as None. BioSQL schema requires a varchar and is not NULL
dbxref_id = self._get_dbxref_id(feature.ref_db or "", feature.ref)
else:
dbxref_id = None
@@ -939,7 +938,7 @@ def _load_seqfeature_dbxref(self, dbxrefs, seqfeature_id):
dbxref_id = self._get_dbxref_id(db, accession)
# Insert the seqfeature_dbxref data
self._get_seqfeature_dbxref(seqfeature_id, dbxref_id, rank+1)
-
+
def _get_dbxref_id(self, db, accession):
""" _get_dbxref_id(self, db, accession) -> Int
@@ -1039,7 +1038,7 @@ def _add_bioentry_dbxref(self, bioentry_id, dbxref_id, rank):
'(%s, %s, %s)'
self.adaptor.execute(sql, (bioentry_id, dbxref_id, rank))
return (bioentry_id, dbxref_id)
-
+
class DatabaseRemover:
"""Complement the Loader functionality by fully removing a database.
View
4 Doc/examples/Proux_et_al_2002_Figure_6.py
@@ -74,10 +74,10 @@
(19, "Tuc2009_46", "orf52"),
(77, "Tuc2009_48", "orf54"),
(91, "Tuc2009_49", "orf55"),
- (95, "Tuc2009_52", "orf60"),
+ (95, "Tuc2009_52", "orf60"),
]
-#bIL285 (AF323668) vs Listeria innocua prophage 5 (in NC_003212)
+#bIL285 (AF323668) vs Listeria innocua prophage 5 (in NC_003212)
B_vs_C = [
(42, "orf39", "lin2581"),
(31, "orf40", "lin2580"),
View
2 Doc/examples/fasta_iterator.py
@@ -42,7 +42,7 @@ def extract_organisms(file_to_parse):
if cur_record is None:
break
-
+
# extract the info from the title
new_species = cur_record.title.split()[1]
View
31 Doc/examples/getgene.py
@@ -6,14 +6,14 @@
""" Example code to index a non-reduntant protein database of
SwissProt + TrEMBL for fast lookup and retrieval.
-
+
To build the database and index it:
cd /opt/bio/data/
wget -N -nd -r -l1 -A'.dat.Z' ftp://expasy.cbr.nrc.ca/databases/sp_tr_nrdb/
zcat *.dat.Z > nr.dat
./getgene.py --index nr.dat
setenv PYPHY '/opt/bio/data'
-
+
To retrieve entries from the command line:
./getgene.py EFTU_ECOLI
@@ -27,8 +27,8 @@
# get organism, lineage and gene
db_index.Get_OS_OC_GN('EFTU_ECOLI')
-"""
-
+"""
+
import os
import re
import string
@@ -38,13 +38,13 @@
class DB_Index:
def __init__(self, open = 1):
if open: self.Open()
-
+
def Create(self, infile, outfile):
db = gdbm.open(outfile, 'n')
fid = open(infile)
db['datafile'] = os.path.abspath(infile)
-
+
while 1:
line = fid.readline()
if not line or not len(line): break
@@ -67,7 +67,7 @@ def Create(self, infile, outfile):
except:
print 'AARRGGGG', start, stop, type(start), type(stop)
print id, acc
-
+
db.close()
fid.close()
@@ -81,7 +81,7 @@ def Open(self, indexfile = None):
def Close(self):
self.db.close()
-
+
def Get(self, id):
try:
values = self.db[id]
@@ -91,7 +91,7 @@ def Get(self, id):
self.fid.seek(start)
txt = self.fid.read(stop - start)
return txt
-
+
def Get_Organism(self, id):
entry = self.Get(id)
if not entry: return None
@@ -107,7 +107,7 @@ def FixOS(self, os):
os = string.split(os,',')[0]
os = string.split(os,'(')[0]
return string.strip(os)
-
+
def Get_Taxonomy(self, id):
entry = self.Get(id)
if not entry: return None
@@ -118,7 +118,7 @@ def Get_Taxonomy(self, id):
if OC[-1] ==".": OC = OC[0:-1]
if line[0:2] =="//": break
return OC
-
+
def Get_Kingdom(self, id):
res = self.Get_Taxonomy(id)
#print id, res
@@ -131,7 +131,7 @@ def Get_Kingdom(self, id):
else:
print kd, "UNKNOWN"
return "U"
-
+
def Get_Gene(self, id):
entry = self.Get(id)
if not entry: return None
@@ -144,7 +144,6 @@ def Get_Gene(self, id):
if line[0:2] =="//": break
return GN
-
def Get_OS_OC_GN(self, id):
entry = self.Get(id)
if not entry: return None, None, None
@@ -161,7 +160,7 @@ def Get_OS_OC_GN(self, id):
if GN[-1] ==".": GN = GN[0:-1]
if line[0:2] =="//": break
return OS, OC, GN
-
+
def Get_OS_OC_OG(self, id):
entry = self.Get(id)
if not entry: return None, None, None
@@ -203,7 +202,7 @@ def Get_XX(self, id, xx):
if XX[-1] ==".": XX = XX[0:-1]
if line[0:2] =="//": break
return XX
-
+
def Get_Keywords(self, id):
entry = self.Get(id)
if not entry: return []
@@ -256,7 +255,7 @@ def help(exit = 0):
ids = sys.argv[2:]
except:
help(exit = 1)
-
+
dbfile = os.path.join(pyphy_home, db + '.indexed')
db_index.Open(dbfile)
for id in ids:
View
4 Doc/examples/local_blast.py
@@ -30,7 +30,7 @@
if b_record is None:
break
-
+
E_VALUE_THRESH = 0.04
for alignment in b_record.alignments:
for hsp in alignment.hsps:
@@ -44,7 +44,7 @@
dots = '...'
else:
dots = ''
-
+
print hsp.query[0:75] + dots
print hsp.match[0:75] + dots
print hsp.sbjct[0:75] + dots
View
20 Doc/examples/nmr/simplepredict.py
@@ -4,8 +4,8 @@
#
# This is an example script for using new biopython modules for
# generating NOE crosspeak peaklists from diagonal peaklist within
-# the framework of nmrview.
-# nmrview is not required to run this script, only an installed
+# the framework of nmrview.
+# nmrview is not required to run this script, only an installed
# version of python.
@@ -36,7 +36,7 @@
# ** Output of this script **
-#
+#
# This script generates a human readable standard output version of the
# NOE coordinates as well as an nmrview peaklist out_example.xpk.
@@ -57,7 +57,7 @@
#sys.path=[sys.path,"./"]
#sys.path=[sys.path,"/usr/people/robert/development/xpktools"]
from Bio.NMR import xpktools # Contains data classes and functions for .xpk files
-from Bio.NMR import NOEtools # A module specific for generate NOE predictions
+from Bio.NMR import NOEtools # A module specific for generate NOE predictions
# * * * * * * * * * * MAIN * * * * * * * * * *
@@ -68,7 +68,7 @@
outfn="./out_example.xpk" # Output peaklist
detectatom="H1" # Directly detected atom
relayatom="N15" # J-coupling from here to detected atom
-fromatom="15N2" # The other labelled nucleus
+fromatom="15N2" # The other labelled nucleus
@@ -77,7 +77,7 @@
# *-*-* that contains methods for easily extracting information from
# *-*-* the peaklist file
-peaklist=xpktools.Peaklist(infn) # infn is the name of the xpk file
+peaklist=xpktools.Peaklist(infn) # infn is the name of the xpk file
@@ -86,15 +86,15 @@
# *-*-* to be separated from the header and returned here to
# *-*-* the dictionary <dict> as a list indexed by the assignment
# *-*-* of any of the nuclei in the file -- here, the detected atom
-# *-*-* is used
+# *-*-* is used
dict=peaklist.residue_dict(detectatom)
# *-*-* As well as the data, the dictionary contains two other entries,
-# *-*-* corresponding to the maximum and minimum residues indexed
+# *-*-* corresponding to the maximum and minimum residues indexed
MAXRES=dict["maxres"]
MINRES=dict["minres"]
@@ -116,7 +116,7 @@
# *-*-* Write each one to the output file as they are calculated
count=0 # A counter that number the output data lines in order
-res=MINRES # minimum residue number in the set
+res=MINRES # minimum residue number in the set
outlist=[] # Holds the output data
@@ -128,7 +128,7 @@
# *-*-* is done by supplying the peaklist to and specifying the label
# *-*-* of the origin and detected atom in the NOE transfer as well as
# *-*-* the residues between which the NOE transfer takes places.
-
+
noe1=NOEtools.predictNOE(peaklist,"15N2","H1",res,res+inc)
noe2=NOEtools.predictNOE(peaklist,"15N2","H1",res,res-inc)
View
8 Scripts/GenBank/check_output.py
@@ -44,7 +44,7 @@ def do_comparison(good_record, test_record):
assert test_line == good_line, \
"Expected does not match Test.\nExpect:`%s`\nTest :`%s`\n" % \
(good_line, test_line)
-
+
def write_format(file):
record_parser = GenBank.RecordParser(debug_level = 2)
@@ -59,11 +59,11 @@ def write_format(file):
iterator = GenBank.Iterator(cur_handle, record_parser)
compare_iterator = GenBank.Iterator(compare_handle)
-
+
while 1:
cur_record = iterator.next()
compare_record = compare_iterator.next()
-
+
if cur_record is None or compare_record is None:
break
@@ -84,4 +84,4 @@ def write_format(file):
print __doc__
sys.exit()
- write_format(sys.argv[1])
+ write_format(sys.argv[1])
View
2 Scripts/GenBank/check_output_simple.py
@@ -30,7 +30,7 @@
if not(cur_record):
break
-
+
print "***Record"
print "Seq:", cur_record.seq
print "Id:", cur_record.id
View
6 Scripts/GenBank/find_parser_problems.py
@@ -27,7 +27,7 @@
while 1:
have_record = 0
-
+
while have_record == 0:
try:
cur_record = iterator.next()
@@ -40,7 +40,7 @@
break
print "Successfully parsed record", cur_record.id
-
+
if verbose:
print "***Record"
print "Seq:", cur_record.seq
@@ -51,5 +51,5 @@
print "Feaures"
for feature in cur_record.features:
print feature
-
+
handle.close()
View
6 Scripts/PDB/generate_three_to_one_dict.py
@@ -7,7 +7,7 @@
"""
Download and parse PDB Chemical Component Dictionary,
-then write out dict for to_one_letter_code.
+then write out dict for to_one_letter_code.
"""
import gzip
@@ -35,7 +35,7 @@
# size as of 13 April 2012
if os.path.getsize(gzname) < 29944258:
- warnings.warn("ERROR: Downloaded file is too small",
+ warnings.warn("ERROR: Downloaded file is too small",
RuntimeWarning)
fh = gzip.open(gzname, 'rb')
@@ -67,7 +67,6 @@
line = fh.readline()
while line:
-
if line.startswith('_chem_comp.one_letter_code'):
one = line.strip().split()[-1]
found_one = True
@@ -93,7 +92,6 @@
found_one = False
found_three = False
-
line = fh.readline()
View
2 Scripts/Performance/biosql_performance_load.py
@@ -5,7 +5,7 @@
# set up the connection
from Bio import GenBank
from BioSQL import BioSeqDatabase
-server = BioSeqDatabase.open_database(host = "192.168.0.192", user = "root",
+server = BioSeqDatabase.open_database(host = "192.168.0.192", user = "root",
passwd = "", db = "pythonloadtest")
# remove the database if it already exists
View
4 Scripts/Performance/biosql_performance_read.py
@@ -4,7 +4,7 @@
import time
# set up the connection
from BioSQL import BioSeqDatabase
-server = BioSeqDatabase.open_database(host = "192.168.0.192", user = "root",
+server = BioSeqDatabase.open_database(host = "192.168.0.192", user = "root",
passwd = "", db = "test_biosql")
db = server["embl_rod"]
@@ -15,7 +15,7 @@
sequence = record.seq.data
d = record.description
i = record.id
- n = record.name
+ n = record.name
end_time = time.time()
num_records = len(all_records)
View
2 Scripts/Restriction/ranacompiler.py
@@ -13,7 +13,7 @@
def standalone() :
- parser = optparse.OptionParser()
+ parser = optparse.OptionParser()
add = parser.add_option
add('-i', '--install',
View
5 Scripts/Restriction/rebase_update.py
@@ -11,7 +11,6 @@
import optparse
from Bio.Restriction._Update.Update import *
-
if __name__ == '__main__' :
parser = optparse.OptionParser()
add = parser.add_option
@@ -27,9 +26,9 @@
dest = 'ftp_proxy',
default = '',
help = "set the proxy to be used by the ftp connection.")
-
+
(option, args) = parser.parse_args()
-
+
Getfiles = RebaseUpdate(option.rebase_password, option.ftp_proxy)
Getfiles.openRebase()
Getfiles.getfiles()
View
4 Scripts/SeqGui/SeqGui.py
@@ -167,13 +167,13 @@ def translate(self, codon_table):
self.dest_text.Clear()
self.dest_text.SetValue(translate(seq, table=codon_table,
to_stop=True))
-
+
def transcribe(self):
seq = "".join(self.src_text.GetValue().split()) #remove whitespace
print seq
self.dest_text.Clear()
self.dest_text.SetValue(transcribe(seq))
-
+
def back_transcribe(self):
seq = "".join(self.src_text.GetValue().split()) #remove whitespace
print seq
View
8 Scripts/debug/debug_blast_parser.py
@@ -71,7 +71,7 @@ def test_blast_output(outfile):
print "No parser specified. I'll try to choose one for you based"
print "on the format of the output file."
print
-
+
parser_class = choose_parser(outfile)
print "It looks like you have given output that should be parsed"
print "with %s.%s. If I'm wrong, you can select the correct parser" %\
@@ -160,7 +160,7 @@ def test_blast_output(outfile):
prefix = '*'
else:
prefix = ' '
-
+
s = "%s%*d %s" % (prefix, ndigits, linenum, line)
s = s[:80]
print s
@@ -190,7 +190,7 @@ def test_blast_output(outfile):
pass
print "*"*20 + " END SCANNER TRACE " + "*"*20
print
-
+
elif class_found == consumer_class:
print "Problems in %s can be caused by two things:" % \
class_found.__name__
@@ -204,7 +204,7 @@ def test_blast_output(outfile):
print s
print "If so, debug %s.%s. Otherwise, debug %s." % \
(class_found.__name__, err_function, scanner_class.__name__)
-
+
VERBOSITY = 0
if __name__ == '__main__':
View
18 Scripts/scop_pdb.py
@@ -27,7 +27,7 @@ def usage() :
Note: Errors will occur if the PDB file has been altered since the creation
of the SCOP CLA and ASTRAL RAF files.
-
+
Usage: scop_pdb [-h] [-i file] [-o file] [-p pdb_url_prefix]
raf_url cla_url [sid] [sid] [sid] ...
@@ -36,7 +36,7 @@ def usage() :
-i file -- Input file name. Each line should start with an sid (Scop domain
identifier). Blank lines, and lines starting with '#' are
ignored. If file is '-' then data is read from stdin. If not
- given then sids are taken from the command line.
+ given then sids are taken from the command line.
-o file -- Output file name. If '-' then data is written to stdout. If not
given then data is written to files named sid+'.ent'.
@@ -52,7 +52,7 @@ def usage() :
cla_url -- The URL or filename of a SCOP parsable CLA file.
See [http://scop.berkeley.edu/parse/index.html]
- sid -- A SCOP domain identifier. e.g. d3hbib_
+ sid -- A SCOP domain identifier. e.g. d3hbib_
"""
@@ -84,7 +84,7 @@ def main():
pdb_url = None
cla_url = None
raf_url = None
-
+
for o, a in opts:
if o in ("-h", "--help","--usage"):
usage()
@@ -103,7 +103,7 @@ def main():
raf_url = args[0]
cla_url = args[1]
-
+
(raf_filename, headers) = urllib.urlretrieve(raf_url)
seqMapIndex = Raf.SeqMapIndex(raf_filename)
@@ -135,15 +135,15 @@ def main():
out_handle = sys.stdout
else :
out_handle = open(output, "w+")
-
+
try:
try:
claRec = claIndex[id]
residues = claRec.residues
seqMap = seqMapIndex.getSeqMap(residues)
pdbid = residues.pdbid
- f = open_pdb(pdbid, pdb_url)
+ f = open_pdb(pdbid, pdb_url)
try:
seqMap.getAtoms(f, out_handle)
finally :
@@ -155,7 +155,7 @@ def main():
finally :
if in_handle is not None:
in_handle.close()
-
-
+
+
if __name__ == "__main__":
main()
View
23 Scripts/xbbtools/nextorf.py
@@ -54,7 +54,7 @@ def __init__(self, file, options):
self.table = makeTableX(CodonTable.ambiguous_dna_by_id[self.genetic_code])
self.counter = 0
self.ReadFile()
-
+
def ReadFile(self):
handle = open(self.file)
for record in SeqIO.parse(handle, "fasta"):
@@ -97,7 +97,7 @@ def Gc2(self,seq):
d= {}
for nt in ['A','T','G','C']:
d[nt] = [0,0,0]
-
+
for i in range(0,l,3):
codon = seq[i:i+3]
if len(codon) <3: codon = codon + ' '
@@ -175,7 +175,7 @@ def GetCDS(self, seq, strand = 1):
elif length < minlength or length > maxlength:
start_site = 0
if nostart == '1': start_site = stop + 1
- del stop
+ del stop
return CDS
def Output(self, CDS):
@@ -188,41 +188,40 @@ def Output(self, CDS):
if strand < 0: head = 'orf_%s:%s:%d:%d:%d' % (self.counter, self.header, strand, n-stop+1,n-start+1)
if self.options['gc']:
head = '%s:%s' % (head, self.Gc2(subs.data))
-
+
if out == 'aa':
orf = subs.translate(table=self.genetic_code)
print self.ToFasta(head, orf.data)
elif out == 'nt':
print self.ToFasta(head, subs.data)
elif out == 'pos':
print head
-
-
-
+
+
def help():
global options
print 'Usage:', sys.argv[0], '(<options>) <FASTA file>'
-
+
print 'Options: default'
print '--start Start position in sequence 0'
print '--stop Stop position in sequence (end of seqence)'
print '--minlength Minimum length of orf in bp 100'
print '--maxlength Maximum length of orf in bp, default 100000000'
print '--strand Strand to analyse [both, plus, minus] both'
print '--frame Frame to analyse [1 2 3] all'
- print '--noframe Ignore start codons [0 1] 0'
+ print '--noframe Ignore start codons [0 1] 0'
print '--output Output to generate [aa nt pos] aa'
print '--gc Creates GC statistics of ORF [0 1] 0'
print '--table Genetic code to use (see below) 1'
-
+
# for a,b in options.items(): print '\t', a,b
# print ''
print "\nNCBI's Codon Tables:"
for key, table in CodonTable.ambiguous_dna_by_id.items():
print '\t',key, table._codon_table.names[0]
print '\ne.g.\n./nextorf.py --minlength 5 --strand plus --output nt --gc 1 testjan.fas'
sys.exit(0)
-
+
options = {
'start': 0,
@@ -255,7 +254,7 @@ def help():
if arg[1].lower() == 'no': arg[1] = 0
elif arg[1].lower() == 'yes': arg[1] = 1
if arg[0][2:] == key: options[key] = arg[1]
-
+
if arg[0] == '-v':print 'OPTIONS', options
file = args[0]
View
20 Scripts/xbbtools/xbb_blast.py
@@ -24,15 +24,15 @@ def __init__(self, seq, parent = None):
Pmw.initialise(parent)
self.GetBlasts()
self.Choices()
-
+
def GetBlasts(self):
pin, nin = [],[]
try:
pin.extend(glob.glob(os.environ['BLASTDB'] + '/*.pin'))
except:
pass
pin.extend(glob.glob('*.pin'))
-
+
try:
nin.extend(glob.glob(os.environ['BLASTDB'] + '/*.nin'))
except:
@@ -68,11 +68,11 @@ def Choices(self):
self.ok = Button(self.alternative_f, text = 'Run',
command = self._Run)
self.ok.pack(side = RIGHT)
-
+
self.dbs.selectitem(0)
self.blasts.selectitem(0)
self.Validate()
-
+
def Validate(self, *args):
db = self.dbs.get()
prog = self.blasts.get()
@@ -85,7 +85,6 @@ def Validate(self, *args):
self.dbs.component('entry').configure(bg = color)
self.blasts.component('entry').configure(bg = color)
-
def _Run(self):
alternative_command = self.alternative.get()
if len(alternative_command.strip()):
@@ -101,26 +100,25 @@ def Update(self):
self.notepad.update()
#print '.',
self.notepad.after(1, self.Update)
-
+
def oldRun(self):
self.notepad = NotePad()
self.notepad.menubar.configure(bg='red')
self.notepad.bind('<Destroy>', self.Exit)
self.Update()
-
+
print self.command
self.pipe = posix.popen(self.command)
while 1:
try:
char = self.pipe.read(1)
self.notepad.insert(END,char)
self.notepad.update()
-
except:
break
if not char: break
-
+
try:
self.notepad.menubar.configure(bg='green')
except:
@@ -140,8 +138,7 @@ def Run(self):
self.notepad.menubar.configure(bg='green4')
except:
pass
-
-
+
def Exit(self, *args):
try:
@@ -152,7 +149,6 @@ def Exit(self, *args):
self.notepad.destroy()
sys.exit(0)
-
View
17 Scripts/xbbtools/xbb_blastbg.py
@@ -20,20 +20,20 @@ class BlastDisplayer:
def __init__(self, command, text_id = None):
self.command = command
self.tid = text_id
-
+
def RunCommand(self):
self.outfile = tempfile.mktemp()
# make sure outfile exists and is empty
fid = open(self.outfile,'w+')
fid.close()
-
+
com = '%s > %s' % (self.command, self.outfile)
self.worker = BlastWorker(com)
self.worker.start()
self.UpdateResults()
-
+
def UpdateResults(self):
# open the oufile and displays new appended text
fid = open(self.outfile)
@@ -52,8 +52,7 @@ def UpdateResults(self):
break
fid.close()
- self.Exit()
-
+ self.Exit()
def Exit(self):
if os.path.exists(self.outfile):
@@ -62,10 +61,10 @@ def Exit(self):
# do I need to stop the queue ?
self.worker.shutdown()
del self.worker
-
-
+
+
class BlastWorker(threading.Thread):
-
+
def __init__(self, command):
self.com = command
queue = Queue.Queue(0)
@@ -79,7 +78,7 @@ def shutdown(self):
# GRRRR How do I explicitely kill a thread ???????
#self.queue.put(None)
del self.queue
-
+
def run(self):
print 'running', self.com
os.system(self.com)
View
1 Scripts/xbbtools/xbb_help.py
@@ -25,7 +25,6 @@ def Styles(self):
self.tid.tag_config('title', font = ('Courier', 12, 'bold'))
self.tid.tag_config('small', font = ('Courier', 6, ''))
self.tid.tag_config('highlight', background = 'gray')
-
def Show(self):
t = self.tid
View
35 Scripts/xbbtools/xbb_search.py
@@ -20,7 +20,7 @@ class DNAsearch:
def __init__(self):
self.init_alphabet()
self.sequence = ''
-
+
def init_alphabet(self):
self.alphabet = ambiguous_dna_values
other = ''.join(self.alphabet.keys())
@@ -31,12 +31,12 @@ def init_alphabet(self):
self.alphabet[key] = self.alphabet[key] + key
def SetSeq(self, seq): self.sequence = seq
-
+
def SetPattern(self, pattern):
self.pattern = pattern
self.rx_pattern = self.IUPAC2regex(pattern)
self.rx = re.compile(self.rx_pattern)
-
+
def IUPAC2regex(self, s):
rx = ''
for i in s:
@@ -46,18 +46,17 @@ def IUPAC2regex(self, s):
else:
rx += r
return rx
-
+
def _Search(self, start = 0):
pos = self.rx.search(self.sequence, start)
return pos
-
+
def Search(self, start = 0):
pos = self.rx.search(self.sequence, start)
if pos:
return pos.start()
else:
return -1
-
def SearchAll(self):
pos = -1
@@ -68,11 +67,11 @@ def SearchAll(self):
pos = m.start()
if pos == -1:
break
-
+
positions.append(pos)
return positions
-
-
+
+
class XDNAsearch(Toplevel, DNAsearch):
def __init__(self, seq= '', master= None, highlight = 0):
DNAsearch.__init__(self)
@@ -82,7 +81,7 @@ def __init__(self, seq= '', master= None, highlight = 0):
self.init_graphics()
self.sequence = seq
self.cur_pos = 0
-
+
def init_graphics(self):
Toplevel.__init__(self, self.master)
self.frame = Frame(self)
@@ -93,7 +92,7 @@ def init_graphics(self):
f2 = Frame(self.frame)
f2.pack(side = TOP, fill = BOTH, expand = 1)
-
+
f = f2
self.forward = Button(f, text = 'Search +', command = self.do_search)
self.forward.pack(side = LEFT)
@@ -107,9 +106,6 @@ def init_graphics(self):
self.colorb.pack(side = LEFT)
self.config_color(self.current_color)
-
-
-
def config_color(self, color = None):
if not self.highlight: return
if not color:
@@ -122,16 +118,16 @@ def config_color(self, color = None):
self.master.tag_config(self.current_tag, background=self.current_color)
self.master.tag_config(self.current_tag+'R', background=self.current_color, underline = 1)
self.colors.append(color)
-
+
def change_color(self):
self.config_color()
self.colorb.configure(foreground = self.current_color)
self.colorb.update()
-
+
def get_pattern(self):
pattern = self.search_entry.get()
return pattern
-
+
def do_search(self, other_strand = 0):
pattern = self.get_pattern()
if other_strand: pattern = reverse_complement(pattern)
@@ -148,19 +144,16 @@ def do_search(self, other_strand = 0):
w.tag_add(self.current_tag, '1.%d' % start, '1.%s' % stop)
w.see('1.%d' % start)
-
-
def exit(self):
for c in self.colors:
self.master.tag_remove('searched_%s' % c, 1.0, END)
self.master.tag_remove('searched_%sR' % c, 1.0, END)
self.destroy()
del(self)
-
+
def showcolor(self):
pass
-
if __name__ == '__main__':
seq = 'ATGGTGTGTGTGTACGATCGCCCCCCCCAGTCGATCGATGCATCGTA'
View
19 Scripts/xbbtools/xbb_translations.py
@@ -29,7 +29,7 @@ def reverse(self, seq):
def antiparallel(self, seq):
return reverse_complement(seq)
-
+
def frame(self, seq, frame, translation_table = 1):
if not ((-3 <= frame <= -1) or (1 <= frame <= 3)):
frame = 1
@@ -47,17 +47,17 @@ def header_nice(self, txt, seq):
short = '%s ... %s' % (seq[:10], seq[-10:])
else:
short = seq
-
+
date = time.strftime('%y %b %d, %X', time.localtime(time.time()))
res = '%s: %s, ' % (txt,date)
for nt in ['a','t','g','c']:
res += '%s:%d ' % (nt, seq.count(nt.upper()))
- res += '\nSequence: %s, %d nt, %0.2f %%GC\n' % (short.lower(),length, self.gc(seq))
+ res += '\nSequence: %s, %d nt, %0.2f %%GC\n' % (short.lower(),length, self.gc(seq))
res += '\n\n'
return res
-
+
def frame_nice(self, seq, frame, translation_table = 1):
length = len(seq)
protein = self.frame(seq, frame, translation_table)
@@ -71,11 +71,11 @@ def frame_nice(self, seq, frame, translation_table = 1):
res += subseq.lower() + '%5d %%\n' % int(self.gc(subseq))
return res
-
+
def gc(self, seq):
"""Returns a float between 0 and 100."""
return GC(seq)
-
+
def gcframe(self, seq, translation_table = 1):
# always use uppercase nt-sequence !!
comp = self.complement(seq)
@@ -104,10 +104,9 @@ def gcframe(self, seq, translation_table = 1):
res += ' '.join(map(None,frames[-2][p:p+20])) + ' \n'
res += ' ' + ' '.join(map(None,frames[-1][p:p+20])) + '\n'
res += ' ' + ' '.join(map(None,frames[-3][p:p+20])) + '\n\n'
-
-
+
return res
-
+
if __name__ == '__main__':
#s = 'GCCCTTTCTTATTAGTGCTACCGCTAATAGGTAAATATGAAAAACCTTTG'
s = 'ATTCCGGTTGATCCTGCCGGACCCGACCGCTATCGGGGTAGGGATAAGCCATGGGAGTCTTACACTCCCGGGTAAGGGAGTGTGGCGGACGGCTGAGTAACACGTGGCTAACCTACCCTCGGGACGGGGATAACCCCGGGAAACTGGGGATAATCCCCGATAGGGAAGGAGTCCTGGAATGGTTCCTTCCCTAAAGGGCTATAGGCTATTTCCCGTTTGTAGCCGCCCGAGGATGGGGCTACGGCCCATCAGGCTGTCGGTGGGGTAAAGGCCCACCGAACCTATAACGGGTAGGGGCCGTGGAAGCGGGAGCCTCCAGTTGGGCACTGAGACAAGGGCCCAGGCCCTACGGGGCGCACCAGGCGCGAAACGTCCCCAATGCGCGAAAGCGTGAGGGCGCTACCCCGAGTGCCTCCGCAAGGAGGCTTTTCCCCGCTCTAAAAAGGCGGGGGAATAAGCGGGGGGCAAGTCTGGTGTCAGCCGCCGCGGTAATACCAGCTCCGCGAGTGGTCGGGGTGATTACTGGGCCTAAAGCGCCTGTAGCCGGCCCACCAAGTCGCCCCTTAAAGTCCCCGGCTCAACCGGGGAACTGGGGGCGATACTGGTGGGCTAGGGGGCGGGAGAGGCGGGGGGTACTCCCGGAGTAGGGGCGAAATCCTTAGATACCGGGAGGACCACCAGTGGCGGAAGCGCCCCGCTA'
@@ -119,6 +118,6 @@ def gcframe(self, seq, translation_table = 1):
#print test.complement(s)
print '============================================================'
print test.gcframe(s)
-
+
# for i in Translate.unambiguous_dna_by_id.keys():
# print Translate.unambiguous_dna_by_id[i].table.names[0]
View
5 Scripts/xbbtools/xbb_utils.py
@@ -17,20 +17,19 @@ def __init__(self, master= None):
self.filemenu.add_command(label = "Save", command = self.save)
self.filemenu.add_separator()
self.filemenu.add_command(label = "Dismiss", command = self.destroy)
-
+
self.menubar.add_cascade(label="File", menu=self.filemenu)
self.configure(menu = self.menubar)
self.yscroll = Scrollbar(self,orient=VERTICAL)
self.tid = Text(self, yscrollcommand = self.yscroll.set)
self.yscroll.configure(command = self.tid.yview)
self.tid.pack(side = LEFT, fill = BOTH, expand = 1)
self.yscroll.pack(side = RIGHT, fill = Y)
-
def text_id(self): return self.tid
def insert(self,start, txt):
self.tid.insert(start, txt)
-
+