Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to python version 3.11 #1167

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.11
- run: mkdir -p ~/bin
- run: echo ~/bin >> $GITHUB_PATH

Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.11

- uses: actions/setup-go@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Check that Python is already installed.

python --version

We have tested with Python 3.8.
We have tested with Python `3.11`.

### BaseSpace
Set up the [native apps virtual machine][bsvm], and configure a shared folder
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# If you omit the `--target` tag altogether, `docker build` will build
# the development image.

FROM python:3.8
FROM python:3.11

MAINTAINER BC CfE in HIV/AIDS https://github.com/cfe-lab/MiCall

Expand Down
2 changes: 1 addition & 1 deletion Singularity
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generate the Singularity container to run MiCall on Kive.
Bootstrap: docker
From: python:3.8
From: python:3.11

%help
MiCall maps all the reads from a sample against a set of reference
Expand Down
2 changes: 1 addition & 1 deletion micall/core/coverage_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def make_tar_path(tar_path):

def parse_args():
parser = argparse.ArgumentParser(description='Generate coverage plots from MiCall outputs.')
parser.add_argument('amino_csv', type=argparse.FileType('rU'),
parser.add_argument('amino_csv', type=argparse.FileType('r'),
help='<input> CSV containing amino acid frequency outputs.')
parser.add_argument('coverage_scores_csv', type=argparse.FileType('w'),
help='<output> CSV coverage scores.')
Expand Down
2 changes: 1 addition & 1 deletion micall/core/filter_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def parse_args():
description='Post-processing of short-read alignments.')

parser.add_argument('quality_csv',
type=argparse.FileType('rU'),
type=argparse.FileType('r'),
help='QC error rate data, grouped by tile')
parser.add_argument('bad_cycles_csv',
type=argparse.FileType('w'),
Expand Down
6 changes: 3 additions & 3 deletions micall/core/remap.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def remap(fastq1: str,
stderr,
callback)
new_counts.update(split_counts)
with open(samfile, 'rU') as f:
with open(samfile, 'r') as f:
for fields in splitter.walk(f):
remap_writer.writerow(dict(zip(SAM_FIELDS, fields)))

Expand Down Expand Up @@ -771,7 +771,7 @@ def map_to_contigs(fastq1,
stderr,
callback)
new_counts.update(split_counts)
with open(samfile, 'rU') as f:
with open(samfile, 'r') as f:
for fields in splitter.walk(f):
write_remap_row(remap_writer, fields)

Expand Down Expand Up @@ -1199,7 +1199,7 @@ def main():
parser.add_argument('fastq1', help='<input> FASTQ containing forward reads')
parser.add_argument('fastq2', help='<input> FASTQ containing reverse reads')
parser.add_argument('contigs_csv',
type=argparse.FileType('rU'),
type=argparse.FileType('r'),
help='<input> CSV containing assembled contigs')
parser.add_argument('remap_csv',
type=argparse.FileType('w'),
Expand Down
2 changes: 1 addition & 1 deletion micall/core/sam2aln.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def parse_args():
parser = argparse.ArgumentParser(
description='Conversion of SAM data into aligned format.')
parser.add_argument('remap_csv',
type=argparse.FileType('rU'),
type=argparse.FileType('r'),
help='<input> SAM output of bowtie2 in CSV format')
parser.add_argument('aligned_csv',
type=argparse.FileType('w'),
Expand Down
4 changes: 2 additions & 2 deletions micall/g2p/fastq_g2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
def parse_args():
parser = argparse.ArgumentParser(description='Calculate g2p scores from amino acid sequences.')

parser.add_argument('fastq1', type=argparse.FileType('rU'),
parser.add_argument('fastq1', type=argparse.FileType('r'),
help='<input> FASTQ file containing read 1 reads')
parser.add_argument('fastq2', type=argparse.FileType('rU'),
parser.add_argument('fastq2', type=argparse.FileType('r'),
help='<input> FASTQ file containing read 2 reads')
parser.add_argument('g2p_csv', type=argparse.FileType('w'),
help='<output> CSV containing g2p predictions.')
Expand Down
2 changes: 1 addition & 1 deletion micall/monitor/update_qai.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def find_pipeline_id(session, pipeline_version):
def load_ok_sample_regions(result_folder):
ok_sample_regions = set()
coverage_file = os.path.join(result_folder, 'coverage_scores.csv')
with open(coverage_file, "rU") as f:
with open(coverage_file, "r") as f:
reader = csv.DictReader(f)
for row in reader:
if row['on.score'] == '4':
Expand Down
2 changes: 1 addition & 1 deletion micall/utils/find_chimera.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def process_file(sample_name, projects, args):

nuc_counts = defaultdict(dict) # {(source, dest): {pos: (agree, disagree)}}
nucleotide_path = os.path.join(args.results, 'nuc.csv')
with open(nucleotide_path, 'rU') as nuc_csv:
with open(nucleotide_path, 'r') as nuc_csv:
reader = DictReader(nuc_csv)
sample_rows = (row for row in reader
if row['sample'] == sample_name)
Expand Down
6 changes: 3 additions & 3 deletions micall/utils/make_fda_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
hyphy = HyPhy._THyPhy (os.getcwd(), 1) # instance of HyPhy
hyphyAlign.change_settings(hyphy) # default settings

handle = open('fda_hcv_polyprotein.fa', 'rU')
handle = open('fda_hcv_polyprotein.fa', 'r')
fasta = convert_fasta(handle)
handle.close()

handle = open('/Users/art/git/MiseqPipeline/projects.json', 'rU')
handle = open('/Users/art/git/MiseqPipeline/projects.json', 'r')
proj = json.load(handle)
handle.close()

Expand All @@ -35,4 +35,4 @@

outfile.close()



2 changes: 1 addition & 1 deletion micall/utils/make_hcv_genotype_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def convert_fasta (lines):
noTerminalPenalty = 1)


with open('HCV_REF_2012_genome.fasta', 'rU') as handle:
with open('HCV_REF_2012_genome.fasta', 'r') as handle:
genomes = convert_fasta(handle) # keep one per genotype

projects = ProjectConfig.loadDefault()
Expand Down
2 changes: 1 addition & 1 deletion micall/utils/project_seeds_from_compendium.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def main():
clean_count = 0
dirty_count = 0
recombinant_names = []
with open(filename, 'rU') as f:
with open(filename, 'r') as f:
reader = csv.reader(f)
for description, seed_seq in reader:
seed_seq = seed_seq.replace('-', '')
Expand Down
2 changes: 1 addition & 1 deletion micall/utils/reference_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def calculate_distance(source, destination):


def plot_distances(projects_filename):
with open(projects_filename, 'rU') as f:
with open(projects_filename, 'r') as f:
config = json.load(f)
populate_key_references(config['regions'])
groups = defaultdict(list)
Expand Down
12 changes: 6 additions & 6 deletions micall/utils/remap_fastq_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def filter_fastqs(self, filename1):
devnull,
devnull,
devnull)
with open(remap_filename, 'rU') as remap_csv:
with open(remap_filename, 'r') as remap_csv:
print('Filtering.')
reader = DictReader(remap_csv)
mapped_qnames = {row['qname']
Expand All @@ -72,7 +72,7 @@ def filter_fastqs(self, filename1):
return filter_name1

def filter_reads(self, filename, filter_name, qnames):
with open(filename, 'rU') as fin, open(filter_name, 'w') as fout:
with open(filename, 'r') as fin, open(filter_name, 'w') as fout:
for read in zip(fin, fin, fin, fin):
qname = read[0].split()[0][1:]
if qname in qnames:
Expand All @@ -92,12 +92,12 @@ def _test(self, read_indexes, debug_file_prefix=None):
trimmed_filename2 = os.path.join(workdir, 'rerun.trimmed2.fastq')
prelim_censored_filename = os.path.join(workdir, 'rerun_censored.prelim.csv')
prelim_trimmed_filename = os.path.join(workdir, 'rerun_trimmed.prelim.csv')
with open(self.bad_cycles_filename, 'rU') as bad_cycles:
with open(self.bad_cycles_filename, 'r') as bad_cycles:
bad_cycles = list(csv.DictReader(bad_cycles))
with open(simple_filename1, 'rU') as simple1, \
with open(simple_filename1, 'r') as simple1, \
open(censored_filename1, 'w') as censored1:
censor(simple1, bad_cycles, censored1, use_gzip=False)
with open(simple_filename2, 'rU') as simple2, \
with open(simple_filename2, 'r') as simple2, \
open(censored_filename2, 'w') as censored2:
censor(simple2, bad_cycles, censored2, use_gzip=False)
with open(prelim_censored_filename, 'w+') as prelim_censored_csv, \
Expand Down Expand Up @@ -205,7 +205,7 @@ def read_fastq(filename, reads):
@param filename: the FASTQ file to open
@param reads: defaultdict({qname: [line1, line2, line3, line4, line1, line2, line3, line4]}
"""
with open(filename, 'rU') as f:
with open(filename, 'r') as f:
for line1, line2, line3, line4 in zip(f, f, f, f):
qname = line1.split()[0]
lines = reads[qname]
Expand Down
4 changes: 2 additions & 2 deletions micall/utils/sam_g2p_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test(remap_lines, temp_prefix, pssm, ruby_script, delete_results=True):
try:
check_call([ruby_script, remap_file.name, nuc_filename, ruby_out_filename],
cwd=ruby_path)
with open(nuc_filename, 'rU') as nuc_csv, \
with open(nuc_filename, 'r') as nuc_csv, \
open(python_out_filename, 'wb') as g2p_csv:

# TODO: update this to the new arguments.
Expand Down Expand Up @@ -83,7 +83,7 @@ def ddmin(remap_lines, temp_prefix, pssm, ruby_script):
return header + remap_lines

def compare_conseqs(txtfilename, ruby_script, pssm):
with open(txtfilename, 'rU') as remap_file:
with open(txtfilename, 'r') as remap_file:
remap_lines = remap_file.readlines()
simple_prefix = os.path.splitext(txtfilename)[0] + '_simple'
if test(remap_lines, simple_prefix, pssm, ruby_script) != 'PASS':
Expand Down
4 changes: 2 additions & 2 deletions micall/utils/sample_fastq.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def parse_args():
parser = argparse.ArgumentParser(
description="Randomly sample reads from FASTQ files for quick processing.")
parser.add_argument('fastq1',
type=argparse.FileType('rU'),
type=argparse.FileType('r'),
help='original FASTQ file of forward reads')
parser.add_argument('fastq2',
type=argparse.FileType('rU'),
type=argparse.FileType('r'),
help='original FASTQ file of reverse reads')
parser.add_argument('short_fastq1',
type=argparse.FileType('w'),
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ authors = [
license = {text = "AGPL-3.0"}
license-files = { paths = ["LICENSE.txt"] }
readme = "README.md"
requires-python = ">=3.8,<3.9"
requires-python = ">=3.11,<3.12"
classifiers = [
"License :: OSI Approved :: GNU Affero General Public License v3",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
Expand Down
Loading