Skip to content

Commit 8a3abb9

Browse files
authored
Merge pull request #208 from evidencebp/master
Pylint alerts corrections as part of an intervention experiment 1853
2 parents 82e2113 + 00612f7 commit 8a3abb9

File tree

18 files changed

+34
-19
lines changed

18 files changed

+34
-19
lines changed

bin/litscan-create-xml-metadata.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def main(conn_string, filename, output):
7979
database = line[1]
8080

8181
# get hit_count
82-
cursor.execute("SELECT hit_count FROM litscan_job WHERE job_id='{0}'".format(job_id.lower()))
82+
cursor.execute(
83+
"SELECT hit_count FROM litscan_job WHERE job_id='{0}'".format(job_id.lower()))
8384
result = cursor.fetchone()
8485
hit_count = str(result[0]) if result else ""
8586

bin/litscan-get-statistics.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def main(database, output):
4747
results['ids_in_use'] = cursor.fetchone()[0]
4848

4949
# number of urs in the current version
50-
cursor.execute(""" SELECT COUNT(DISTINCT job_id) FROM litscan_database WHERE job_id like 'urs%' """)
50+
cursor.execute(
51+
""" SELECT COUNT(DISTINCT job_id) FROM litscan_database WHERE job_id like 'urs%' """)
5152
results['urs'] = cursor.fetchone()[0]
5253

5354
# number of expert dbs

bin/litscan-retracted-articles.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def main(database, webhook):
7777
message = f'{len(retracted_articles)} {"articles have" if len(retracted_articles) > 1 else "article has"} ' \
7878
f'been retracted: {", ".join(retracted_articles)}'
7979
requests.post(webhook, json.dumps({"text": message}))
80-
except (Exception, psycopg2.DatabaseError) as error:
80+
except (ValueError, psycopg2.DatabaseError) as error:
8181
requests.post(webhook, json.dumps({"text": error}))
8282
finally:
8383
if conn is not None:

rnacentral_pipeline/cli/ensembl.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def parse_data(division, embl_file, gff_file, output, family_file=None):
8989
writer.write(entries)
9090
except ValueError:
9191
print("Empty entries, implies no ncRNAs. You should check that")
92-
message = f"No ncRNA entries found for {embl_file.name}, or {gff_file.name}. Empty data supplied for now, but you should check the legitimacy of this result.\n"
92+
message = (f"No ncRNA entries found for {embl_file.name}, or {gff_file.name}. "
93+
+ "Empty data supplied for now"
94+
+ ", but you should check the legitimacy of this result.\n")
9395
message += "For reference, the other parameters to the parser were:\n"
9496
message += f"division: {division}\n"
9597
message += f"embl_file: {embl_file.name}\n"

rnacentral_pipeline/databases/europepmc/stream.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def fallback(data):
4040
try:
4141
ref = fetch.lookup(id_ref)
4242
yield id_ref, ref, rows
43-
except Exception:
43+
except (fetch.UnknownReference, fetch.TooManyPublications):
4444
pass
4545

4646

rnacentral_pipeline/databases/evlncrnas/lookup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def mapping(db_url, data):
105105

106106

107107
def as_mapping(db_url, data):
108-
# data = data.explode('Aliases').drop_duplicates(subset='Aliases').rename(columns={'Aliases':'external_id'})#.set_index('external_id')
108+
# data = data.explode('Aliases').drop_duplicates(subset='Aliases').rename(
109+
# columns={'Aliases':'external_id'})#.set_index('external_id')
109110
print(len(data))
110111
data = data.drop(data[data["Name"] == " "].index)
111112
print(data)

rnacentral_pipeline/databases/evlncrnas/parser.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ def parse(db_dir: Path, db_dumps: tuple[Path], db_url: str) -> None:
270270
) #
271271

272272
## Match with RNAcentral based on the gene name
273-
## This is optionally chunked to save memory - split the lookup file and provide a list on the commandline
273+
## This is optionally chunked to save memory -
274+
## split the lookup file and provide a list on the commandline
274275
matched_frame = pd.concat(
275276
[get_db_matches(no_accession_frame, dump_chunk) for dump_chunk in db_dumps]
276277
)

rnacentral_pipeline/databases/hgnc/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def ensembl_sequence(context: Context, ensembl_id: str) -> ty.Optional[str]:
124124
response = requests.get(url)
125125
try:
126126
response.raise_for_status()
127-
except Exception:
127+
except requests.exceptions.HTTPError:
128128
return None
129129
return response.text
130130

rnacentral_pipeline/databases/mgnify/prepare.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def prepare_mgnify_data(data, conn_str):
3737
## Define fallback taxids of the general metagenome of the environment
3838
## These are used if we can't do any better
3939
fallback = {
40-
"zebrafish fecal genome catalogue": 1331678, # zebrafish metagenome - more accurate then generic fish fecal?
40+
"zebrafish fecal genome catalogue": 1331678, # zebrafish metagenome -
41+
# more accurate then generic fish fecal?
4142
"human gut genome catalogue": 408170, # human gut metagenome
4243
"human oral genome catalogue": 447426, # human oral metagenome
4344
"marine genome catalogue": 2994539, # human skin metagenome

rnacentral_pipeline/databases/plncdb/parser.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def parse(data:pathlib.Path) -> ty.Iterable[Entry]:
9696
species_info["taxid"] = species_info["Species"].apply(phy.taxid)
9797

9898

99-
total_entries = len(gff_db.execute("select DISTINCT(id) from features where featuretype = 'transcript' ").fetchall())
99+
total_entries = len(gff_db.execute(
100+
"select DISTINCT(id) from features where featuretype = 'transcript' ").fetchall())
100101
entries = []
101102
for gene_id_q in tqdm(gff_db.execute("select id from features"), total=total_entries):
102103
primary_id = gene_id_q["id"]

rnacentral_pipeline/databases/psi_mi/tab.py

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def as_pubs(value):
120120
refs.append(pubs.reference(ident.value))
121121
except data.UnknownPublicationType:
122122
LOGGER.warn("Could not handle publication %s", ident)
123-
pass
124123
return refs
125124

126125

rnacentral_pipeline/databases/tmrna/helpers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ async def fetch_records(session, accessions: ty.List[str]):
1515
try:
1616
accession_str = ",".join(accessions)
1717
async with session.get(
18-
f"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id={accession_str}&rettype=gb&retmode=text"
18+
("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?"
19+
+ f"db=nuccore&id={accession_str}&rettype=gb&retmode=text")
1920
) as response:
2021
records_text = await response.text()
2122
handle = io.StringIO(records_text)

rnacentral_pipeline/rnacentral/genome_mapping/blat.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"qBaseInsert", # Number of bases inserted in query
4141
"tNumInsert", # Number of inserts in target
4242
"tBaseInsert", # Number of bases inserted in target
43-
"strand", # "+" or "-" for query strand. For translated alignments, second "+"or "-" is for target genomic strand.
43+
"strand", # "+" or "-" for query strand. For translated alignments,
44+
# second "+"or "-" is for target genomic strand.
4445
"qName", # Query sequence name
4546
"qSize", # Query sequence size.
4647
"qStart", # Alignment start position in query
@@ -50,7 +51,10 @@
5051
"tStart", # Alignment start position in target
5152
"tEnd", # Alignment end position in target
5253
"blockCount", # Number of blocks in the alignment (a block contains no gaps)
53-
"blockSizes", # Comma-separated list of sizes of each block. If the query is a protein and the target the genome, blockSizes are in amino acids. See below for more information on protein query PSLs.
54+
"blockSizes", # Comma-separated list of sizes of each block.
55+
# If the query is a protein and the target the genome,
56+
# blockSizes are in amino acids.
57+
# See below for more information on protein query PSLs.
5458
"qStarts", # Comma-separated list of starting positions of each block in query
5559
"tStarts", # Comma-separated list of starting positions of each block in target
5660
]

rnacentral_pipeline/rnacentral/genome_mapping/igv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def ftp(host):
3838

3939
try:
4040
conn.quit()
41-
except Exception as err:
41+
except ftplib.all_errors as err:
4242
LOGGER.info("Failed to close FTP connection")
4343
LOGGER.exception(err)
4444

rnacentral_pipeline/rnacentral/precompute/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def entropy(data):
7676
structures) the name will be very long because it contains the sequence
7777
itself. For example:
7878
79-
RNA (5'-R(*GP*UP*GP*GP*UP*CP*UP*GP*AP*UP*GP*AP*GP*GP*CP*C)-3') from synthetic construct (PDB 3D0M, chain X)
79+
RNA (5'-R(*GP*UP*GP*GP*UP*CP*UP*GP*AP*UP*GP*AP*GP*GP*CP*C)-3')
80+
from synthetic construct (PDB 3D0M, chain X)
8081
8182
This is not a useful name, but it is very long. Thus we do not want it.
8283
What we are generally after is something with the most information (to a

rnacentral_pipeline/rnacentral/r2dt/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def parse(
9494

9595
try:
9696
info.validate()
97-
except Exception as e:
97+
except AssertionError as e:
9898
if allow_missing:
9999
LOGGER.warn("Did not find all required files for %s", urs)
100100
LOGGER.exception(e)

rnacentral_pipeline/rnacentral/search_export/compare.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def compare(output, results1, results2, facet):
7575

7676
def write(output: ty.IO):
7777
""" """
78-
index1 = "http://www.ebi.ac.uk/ebisearch/ws/rest/rnacentral?query={query}&format=json&facetfields={facet}&facetcount=30"
78+
index1 = ("http://www.ebi.ac.uk/ebisearch/ws/rest/rnacentral"
79+
+ "?query={query}&format=json&facetfields={facet}&facetcount=30")
7980
index2 = index1.replace("http://www.", "http://wwwdev.")
8081
queries = ["RNA", 'TAXONOMY:"9606"'] + EXPERT_DATABASES
8182
facets = ["rna_type", "has_genomic_coordinates"]

rnacentral_pipeline/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def __init__(self, co):
3737
self.done = False
3838
self.result = None
3939
self.lock = threading.RLock()
40-
## This needs to be a re-rntrant lock so it is only release by the coroutine that acquired it
40+
## This needs to be a re-rntrant lock so it is only
41+
## release by the coroutine that acquired it
4142

4243
def __await__(self):
4344
with self.lock:

0 commit comments

Comments
 (0)