remove spurious print statements (#4198)

* remove spurious print statements

* remove unneeded import

* add comment
This commit is contained in:
mdehoon
2022-12-13 18:22:11 +09:00
committed by GitHub
parent 549b31f608
commit 5ffdce852b
20 changed files with 75 additions and 28 deletions

View File

@ -2623,8 +2623,8 @@ class Alignment:
to a sort value. For example, you could sort on the GC content of each
sequence.
>>> from Bio.SeqUtils import GC
>>> alignment.sort(key=GC)
>>> from Bio.SeqUtils import gc_fraction
>>> alignment.sort(key=gc_fraction)
>>> print(alignment)
target 0 AATAA 5
0 ||.|| 5
@ -2633,7 +2633,7 @@ class Alignment:
You can reverse the sort order by passing `reverse=True`:
>>> alignment.sort(key=GC, reverse=True)
>>> alignment.sort(key=gc_fraction, reverse=True)
>>> print(alignment)
target 0 AAGAA 5
0 ||.|| 5

View File

@ -247,8 +247,6 @@ class AlignmentIterator(interfaces.AlignmentIterator):
if consensus:
rows, columns = alignment.shape
if len(consensus) != columns:
for aligned_seq in aligned_seqs:
print(aligned_seq, len(aligned_seq))
raise ValueError(
"Alignment has %i columns, consensus length is %i, '%s'"
% (columns, len(consensus), consensus)

View File

@ -18,20 +18,30 @@ Classes:
Examples
--------
You need to download the Cellosaurus database for this examples to
run, e.g. from ftp://ftp.expasy.org/databases/cellosaurus/cellosaurus.txt
This example downloads the Cellosaurus database and parses it. Note that
urlopen returns a stream of bytes, while the parser expects a stream of plain
string, so we use TextIOWrapper to convert bytes to string using the UTF-8
encoding. This is not needed if you download the cellosaurus.txt file in
advance and open it (see the comment below).
>> from Bio.ExPASy import cellosaurus
>> with open('cellosaurus.txt') as handle:
... records = cellosaurus.parse(handle)
... for record in records:
... if 'Homo sapiens' in record['OX'][0]:
... print(record['ID'])
>>> from urllib.request import urlopen
>>> from io import TextIOWrapper
>>> from Bio.ExPASy import cellosaurus
>>> url = "ftp://ftp.expasy.org/databases/cellosaurus/cellosaurus.txt"
>>> bytestream = urlopen(url)
>>> textstream = TextIOWrapper(bytestream, "UTF-8")
>>> # alternatively, use
>>> # textstream = open("cellosaurus.txt")
>>> # if you downloaded the cellosaurus.txt file in advance.
>>> records = cellosaurus.parse(textstream)
>>> for record in records:
... if 'Homo sapiens' in record['OX'][0]:
... print(record['ID']) # doctest:+ELLIPSIS
...
#15310-LN
#W7079
(L)PC6
00136
0.5alpha
...
"""
@ -188,3 +198,9 @@ def __read(handle):
continue
if record:
raise ValueError("Unexpected end of stream")
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()

View File

@ -55,9 +55,7 @@ class Record:
output += f"{key}: {contents[:40]}\n"
output += out_block(contents[40:])
else:
print(contents)
output += f"{key}: {contents[:40]}\n"
output += out_block(contents[40:])
raise RuntimeError(f"unexpected contents of type {type(contents)}")
col_keys = sorted(self.col_defs)
output += "Column Header Definitions\n"
for key in col_keys:

View File

@ -210,3 +210,9 @@ def read(handle):
"""
records = parse(handle)
return next(records)
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()

View File

@ -707,7 +707,6 @@ class Nexus:
file_contents = input
self.filename = "input_string"
else:
print(input.strip()[:50])
raise NexusError(f"Unrecognized input: {input[:100]} ...") from None
file_contents = file_contents.strip()
if file_contents.startswith("#NEXUS"):

View File

@ -438,7 +438,6 @@ def _sff_do_slow_index(handle):
"byte padding region contained data" % padding,
BiopythonParserWarning,
)
# print("%s %s %i" % (read, name, record_offset))
yield name, record_offset
if handle.tell() % 8 != 0:
raise ValueError("After scanning reads, did not end on a multiple of 8")

View File

@ -642,7 +642,6 @@ class FastqRandomAccess(SeqFileRandomAccess):
raise ValueError("Problem with quality section")
yield id.decode(), start_offset, length
start_offset = end_offset
# print("EOF")
def get_raw(self, offset):
"""Return the raw record from the file as a bytes string."""

View File

@ -159,3 +159,9 @@ class IsoelectricPoint:
next_pH = (min_ + max_) / 2
return self.pi(next_pH, min_, max_)
return pH
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()

View File

@ -39,7 +39,7 @@ sorted into the right place.
see _RecordConsumer for details.
The second option is to iterate over the contigs of an ace file one by one
The second option is to iterate over the contigs of an ace file one by one
in the usual way::
from Bio.Sequencing import Ace

View File

@ -197,3 +197,9 @@ def _read(handle):
record.seq_trimmed = record.seq[first:last]
return record
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()

View File

@ -6,7 +6,6 @@
"""Code to parse the keywlist.txt file from SwissProt/UniProt.
See:
- https://www.uniprot.org/docs/keywlist
- https://www.uniprot.org/docs/keywlist.txt
Classes:
@ -85,7 +84,7 @@ def parse(handle):
elif key in ("DE", "SY", "GO", "HI", "WW"):
record[key].append(value)
else:
print(f"Ignoring: {line.strip()}")
raise ValueError(f"Cannot parse line '{line.strip()}'")
# Read the footer and throw it away
for line in handle:
pass

View File

@ -737,8 +737,6 @@ class JASPAR5:
if where_clauses:
sql = "".join([sql, " where ", " and ".join(where_clauses)])
# print("sql = %s" % sql)
cur.execute(sql)
rows = cur.fetchall()

View File

@ -131,3 +131,9 @@ def __make_diagram(record, sequence_tree):
# remove 0-length gaps
motifs_with_gaps = [s for s in motifs_with_gaps if s != "0"]
return "-".join(motifs_with_gaps)
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()

View File

@ -193,3 +193,9 @@ def __convert_strand(strand):
return "-"
if strand == "plus" or strand == "none":
return "+"
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()

View File

@ -191,3 +191,9 @@ def _read_motif_name(handle):
words = line.split()
name = " ".join(words[0:2])
return name
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()

View File

@ -84,7 +84,7 @@ write in JSON format.
"""
from Bio.File import as_handle
from . import phen_micro
from Bio.phenotype import phen_micro
# Convention for format names is "mainname-format" in lower case.
@ -226,3 +226,9 @@ def read(handle, format):
if second is not None:
raise ValueError("More than one record found in handle")
return first
if __name__ == "__main__":
from Bio._utils import run_doctest
run_doctest()

View File

@ -64,6 +64,7 @@ EXCLUDE_DOCTEST_MODULES = ["Bio.Alphabet"]
ONLINE_DOCTEST_MODULES = [
"Bio.Entrez",
"Bio.ExPASy",
"Bio.ExPASy.cellosaurus",
"Bio.TogoWS",
]

View File

@ -459,7 +459,6 @@ class TestSelf(unittest.TestCase):
def fileiter(handle):
for record in SffIterator(handle):
# print(record.id)
i = record.id
self.assertRaises(ValueError, fileiter, handle)

View File

@ -21,7 +21,6 @@ except ImportError:
from Bio import Align, SeqIO
from Bio.Seq import Seq, reverse_complement
from Bio.SeqRecord import SeqRecord
from Bio.SeqUtils import GC
class TestAlignerProperties(unittest.TestCase):