diff --git a/.github/workflows/ci-with-conda.yml b/.github/workflows/ci-with-conda.yml new file mode 100644 index 0000000..3398ce8 --- /dev/null +++ b/.github/workflows/ci-with-conda.yml @@ -0,0 +1,40 @@ +name: Python Package using Conda + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: '3.10' + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + - name: Install dependencies + run: | + conda install -c conda-forge mamba + mamba env update --file mbarq_environment.yaml --name base + pip install . + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + conda install pytest + pytest diff --git a/mbarq/analysis.py b/mbarq/analysis.py index f878d3d..f17da81 100644 --- a/mbarq/analysis.py +++ b/mbarq/analysis.py @@ -383,12 +383,14 @@ def process_results(self, contrasts_run=()): self.logger.info('Writing out final results.') if not contrasts_run: contrasts_run = self.sd.contrasts - try: - res = pd.concat([pd.read_table(self.output_dir / f"{self.name}_{i}_vs_{self.sd.baseline}.gene_summary.txt") - .assign(contrast=i) for i in contrasts_run]) - except: - print(f"Warning: No such file or directory: {self.output_dir}/{self.name}_{i}_vs_{self.sd.baseline}.gene_summary.txt") - + contrast_dfs = [] + for con in contrasts_run: + try: + contrast_dfs.append(pd.read_table(self.output_dir / f"{self.name}_{con}_vs_{self.sd.baseline}.gene_summary.txt") + .assign(contrast=con)) + except: + print(f"Warning: No such file or directory: {self.output_dir}/{self.name}_{con}_vs_{self.sd.baseline}.gene_summary.txt") + res = pd.concat(contrast_dfs) bc_res = pd.concat([pd.read_table(self.output_dir / f"{self.name}_{i}_vs_{self.sd.baseline}.sgrna_summary.txt") .assign(contrast=i) for i in contrasts_run]).rename({'sgrna': 'barcode', 'Gene': 'Name'}, axis=1) fres = res[['id', 'num', 'neg|lfc', 'neg|fdr', 'pos|fdr', 'contrast']] diff --git a/mbarq_environment.yaml b/mbarq_environment.yaml index 76942ff..ee6c304 100644 --- a/mbarq_environment.yaml +++ b/mbarq_environment.yaml @@ -5,12 +5,12 @@ channels: - defaults dependencies: - mageck - - python==3.8.* + - python>=3.8 - blast==2.9.* - bedtools==2.30.* - biopython==1.79 - - numpy=1.22.1 - - pandas==1.3.3 + - numpy=1.22 + - pandas - pytest - click - pip