Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Apr 29, 2024
1 parent c573f16 commit 1bf30e6
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 37 deletions.
20 changes: 10 additions & 10 deletions jcvi/apps/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,19 +632,17 @@ def blast_main(args, dbtype=None):
logging.fatal("`%s` not found on PATH. Have you installed BLAST?", bin)
sys.exit(1)

db_suffix = '.nin' if dbtype == "nucl" else ".pin"
db_suffix = ".nin" if dbtype == "nucl" else ".pin"

run_formatdb(
infile=subject,
outfile=subject + db_suffix,
dbtype=dbtype)
run_formatdb(infile=subject, outfile=subject + db_suffix, dbtype=dbtype)

blastfile = get_outfile(subject, query, suffix="last", outdir=opts.outdir)
# Make several attempts to run LASTAL
try:
sh(
cmd + f" -num_threads {cpus} -query {query} -db {subject} -out {blastfile}" +
" -outfmt 6 -max_target_seqs 1000 -evalue 1e-5",
cmd
+ f" -num_threads {cpus} -query {query} -db {subject} -out {blastfile}"
+ " -outfmt 6 -max_target_seqs 1000 -evalue 1e-5",
check=False,
redirect_error=STDOUT,
)
Expand Down Expand Up @@ -693,14 +691,16 @@ def diamond_blastp_main(args, dbtype="prot"):

run_diamond_makedb(
infile=subject,
outfile=subject + '.dmnd',)
outfile=subject + ".dmnd",
)

blastfile = get_outfile(subject, query, suffix="last", outdir=opts.outdir)
# Make several attempts to run LASTAL
try:
sh(
cmd + f" --threads {cpus} --query {query} --db {subject} --out {blastfile}" +
" --ultra-sensitive --max-target-seqs 1000 --evalue 1e-5 --outfmt 6",
cmd
+ f" --threads {cpus} --query {query} --db {subject} --out {blastfile}"
+ " --ultra-sensitive --max-target-seqs 1000 --evalue 1e-5 --outfmt 6",
check=False,
redirect_error=STDOUT,
)
Expand Down
1 change: 1 addition & 0 deletions jcvi/apps/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Wrapper for fetching data from various online repositories \
(Entrez, Ensembl, Phytozome, and SRA)
"""

import logging
import os.path as op
import re
Expand Down
1 change: 1 addition & 0 deletions jcvi/apps/grid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Codes to submit multiple jobs to JCVI grid engine
"""

import os.path as op
import sys
import re
Expand Down
1 change: 0 additions & 1 deletion jcvi/assembly/goldenpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ def otype(self):


class CertificateLine(object):

"""
North chr1 2 0 AC229737.8 telomere 58443
South chr1 2 1 AC229737.8 AC202463.29 58443 37835 58443 + Non-terminal
Expand Down
6 changes: 3 additions & 3 deletions jcvi/assembly/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def __init__(self, filename, human=False):
# Sample_RF37-1/RF37-1_GATCAG_L008_R2_fastqc =>
# RF37-1_GATCAG_L008_R2
self["Filename"] = op.basename(op.split(filename)[0]).rsplit("_", 1)[0]
self["Total Sequences"] = self["Sequence length"] = self[
"Total Bases"
] = "na"
self["Total Sequences"] = self["Sequence length"] = self["Total Bases"] = (
"na"
)
return

fp = open(filename)
Expand Down
10 changes: 3 additions & 7 deletions jcvi/compara/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def ortholog(args):
"--ignore_zero_anchor",
default=False,
action="store_true",
help="Ignore this pair of ortholog identification instead of throwing an error when performing many pairs of cataloging."
help="Ignore this pair of ortholog identification instead of throwing an error when performing many pairs of cataloging.",
)

p.add_option(
Expand Down Expand Up @@ -708,13 +708,9 @@ def ortholog(args):
last = pprefix + ".last"
if need_update((afasta, bfasta), last, warn=True):
if align_soft == "blast":
blast_main(
[bfasta, afasta, cpus_flag], dbtype
)
blast_main([bfasta, afasta, cpus_flag], dbtype)
elif dbtype == "prot" and align_soft == "diamond_blastp":
diamond_blastp_main(
[bfasta, afasta, cpus_flag], dbtype
)
diamond_blastp_main([bfasta, afasta, cpus_flag], dbtype)
else:
last_main([bfasta, afasta, cpus_flag], dbtype)

Expand Down
8 changes: 4 additions & 4 deletions jcvi/formats/agp.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def order(self):
Returns a dict with component_id => (i, agpline)
"""
d = {}
for (i, x) in enumerate(self):
for i, x in enumerate(self):
if x.is_gap:
continue
xid = x.component_id
Expand Down Expand Up @@ -1293,9 +1293,9 @@ def stats(args):
for label, lengths in zip(("Gaps", "Components"), (gap_lengths, component_lengths)):

if not lengths:
table[(label, "Min")] = table[(label, "Max")] = table[
(label, "Sum")
] = "n.a."
table[(label, "Min")] = table[(label, "Max")] = table[(label, "Sum")] = (
"n.a."
)
continue

table[(label, "Min")] = "{0} ({1})".format(*min(lengths))
Expand Down
7 changes: 6 additions & 1 deletion jcvi/formats/bed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Classes to handle the .bed files
"""

import logging
import math
import numpy as np
Expand Down Expand Up @@ -151,7 +152,11 @@ def __init__(self, filename=None, key=None, sorted=True, juncs=False, include=No
return

for line in must_open(filename):
if line[0] == "#" or (juncs and line.startswith("track name")) or line.strip()=="":
if (
line[0] == "#"
or (juncs and line.startswith("track name"))
or line.strip() == ""
):
continue
b = BedLine(line)
if include and b.accn not in include:
Expand Down
1 change: 0 additions & 1 deletion jcvi/formats/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def overlap(self, max_hang=100):


class Coords(LineFile):

"""
when parsing the .coords file, first skip first 5 lines
[S1] [E1] | [S2] [E2] | [LEN 1] [LEN 2] | [% IDY] | [TAGS]
Expand Down
1 change: 1 addition & 0 deletions jcvi/formats/fasta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Wrapper for biopython Fasta, add option to parse sequence headers
"""

import re
import sys
import os
Expand Down
4 changes: 2 additions & 2 deletions jcvi/formats/genbank.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(self, filenames=None, accessions=None, idfile=None):
next(iter(SeqIO.to_dict(SeqIO.parse(f, "gb")).items()))
for f in filenames
)
for (k, v) in d.items():
for k, v in d.items():
self[k.split(".")[0]] = v

elif idfile is not None:
Expand All @@ -150,7 +150,7 @@ def __init__(self, filenames=None, accessions=None, idfile=None):
next(iter(SeqIO.to_dict(SeqIO.parse(f, "gb")).items()))
for f in glob(gbdir + "/*.gb")
)
for (k, v) in d.items():
for k, v in d.items():
self[k.split(".")[0]] = v

else:
Expand Down
2 changes: 1 addition & 1 deletion jcvi/formats/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def cat(args):
merger = PdfFileMerger()
in_fs = {}
try:
for (filename, page_range) in filename_page_ranges:
for filename, page_range in filename_page_ranges:
if verbose:
print(filename, page_range, file=sys.stderr)
if filename not in in_fs:
Expand Down
4 changes: 2 additions & 2 deletions jcvi/graphics/blastplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def blastplot(

# plot the chromosome breaks
logging.debug("xbreaks={0} ybreaks={1}".format(len(qsizes), len(ssizes)))
for (seqid, beg, end) in qsizes.get_breaks():
for seqid, beg, end in qsizes.get_breaks():
ignore = abs(end - beg) < ignore_size_x
if ignore:
continue
Expand All @@ -135,7 +135,7 @@ def blastplot(
xchr_labels.append((seqid, (beg + end) / 2, ignore))
ax.plot([end, end], ylim, "-", lw=1, color="grey")

for (seqid, beg, end) in ssizes.get_breaks():
for seqid, beg, end in ssizes.get_breaks():
ignore = abs(end - beg) < ignore_size_y
if ignore:
continue
Expand Down
2 changes: 1 addition & 1 deletion jcvi/graphics/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def loghistogram(data, base=2, title="Counts", summary=False):

x, y = [], []
for size, number in sorted(bins.items()):
lb, ub = base ** size, base ** (size + 1)
lb, ub = base**size, base ** (size + 1)
x.append((lb, ub))
y.append(number)

Expand Down
4 changes: 2 additions & 2 deletions jcvi/projects/str.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def mendelian2(args):
m = mendelian_check(tp1, tp2, tpp, is_xlinked=is_xlinked)
counts[m] += 1
if is_xlinked:
for (p, p_sex) in ((tp1, p1_sex), (tp2, p2_sex), (tpp, proband_sex)):
for p, p_sex in ((tp1, p1_sex), (tp2, p2_sex), (tpp, proband_sex)):
if p[1].startswith("-"):
p[1] = "n.a."
cells = [shorten(p1), p1_sex] + tp1[1:]
Expand Down Expand Up @@ -591,7 +591,7 @@ def depth(args):
data = pd.read_csv(tsvfile, sep="\t", low_memory=False)

ids, treds = read_treds()
for (dp, ax, title) in zip(
for dp, ax, title in zip(
("FDP", "PDP", "RDP", "PEDP"),
(ax1, ax2, ax3, ax4),
("Spanning reads", "Partial reads", "Repeat-only reads", "Paired-end reads"),
Expand Down
2 changes: 1 addition & 1 deletion jcvi/projects/sugarcane.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def divergence(args):
}
# Get median for each genome pair
medians = {}
for (g1, g2) in product(SPECIES_CONFIG.keys(), repeat=2):
for g1, g2 in product(SPECIES_CONFIG.keys(), repeat=2):
g1, g2 = sorted((g1, g2))
d = data_by_genomes[(g1, g2)]
medians[(g1, g2)] = np.median(d)
Expand Down
1 change: 1 addition & 0 deletions jcvi/utils/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Useful recipes from various internet sources (thanks)
mostly decorator patterns
"""

import os.path as op
import re
import sys
Expand Down
2 changes: 1 addition & 1 deletion jcvi/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# set up valid database connection params
valid_dbconn = AutoVivification()
for (dbconn, port, module, host) in zip(
for dbconn, port, module, host in zip(
("Sybase", "MySQL", "PostgreSQL", "Oracle"),
(2025, 3306, 5432, 1521),
("Sybase", "MySQLdb", "psycopg2", "cx_Oracle"),
Expand Down

0 comments on commit 1bf30e6

Please sign in to comment.