Compare commits

...

12 Commits

Author SHA1 Message Date
37e6bbba1f Changed publish step to not throw error if the version is already published
All checks were successful
filterfasta/pipeline/head This commit looks good
2025-01-07 20:14:44 +00:00
b94643d36b Merge branch 'master' into develop
Some checks failed
filterfasta/pipeline/head There was a failure building this commit
2024-11-14 21:20:33 +00:00
59f007873c Publish CI step no longer fails build if push is failed
Some checks failed
filterfasta/pipeline/head There was a failure building this commit
2024-11-14 21:18:56 +00:00
6de659df58 Added kubernetes selector.
Some checks failed
filterfasta/pipeline/head There was a failure building this commit
2024-11-14 21:09:53 +00:00
bf357a5524 Updated CI config to mirror serverside config
Some checks failed
filterfasta/pipeline/head There was a failure building this commit
2024-11-14 21:06:14 +00:00
1b08cee027 Bumped version number
All checks were successful
ydeng/filterfasta/pipeline/head This commit looks good
2023-07-25 15:56:35 +00:00
c9bc645cc3 Updated pipeline to take advantage of new build container image
Some checks reported errors
ydeng/filterfasta/pipeline/head Something is wrong with the build of this commit
2023-05-03 08:34:50 -05:00
9dce2d26b6 Merge branch 'master' into develop
All checks were successful
ydeng/filterfasta/pipeline/head This commit looks good
2023-04-24 09:46:25 -05:00
953bb8f507 Refactored code structure and added steps to CI
All checks were successful
ydeng/filterfasta/pipeline/head This commit looks good
CI now archives build and tests if CLI works
2023-04-24 09:45:47 -05:00
a6871214a4 Added test to check installation
All checks were successful
ydeng/filterfasta/pipeline/head This commit looks good
2023-04-22 16:33:30 -05:00
6e6d7a6c43 Added all resources required for a Jenkins pipeline
All checks were successful
ydeng/filterfasta/pipeline/head This commit looks good
2023-04-21 12:21:41 -05:00
43787805e0 Restructured code and renamed project 2023-04-21 12:16:29 -05:00
14 changed files with 191 additions and 70 deletions

View File

@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

25
.gitignore vendored
View File

@@ -1,5 +1,21 @@
# Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,python
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,python
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### Python ###
# Byte-compiled / optimized / DLL files
@@ -192,4 +208,7 @@ pyrightconfig.json
.history
.ionide
# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,python
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

5
.vscode/launch.json vendored
View File

@@ -8,11 +8,12 @@
"name": "Run Fasta Filter",
"type": "python",
"request": "launch",
"program": "fasta_filter.py",
"module": "filterfasta.cli",
"args": [
"reference_standards.fas",
"reference_standards_filtered.fas",
"-c", "rt"
"-c",
"rt"
],
"console": "integratedTerminal",
"justMyCode": true

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"python.formatting.provider": "black"
}

42
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,42 @@
pipeline {
agent {
kubernetes {
cloud 'rsys-devel'
defaultContainer 'pip'
inheritFrom 'pip'
}
}
stages {
stage("install") {
steps {
sh 'pip install -r requirements.txt'
}
}
stage("build") {
steps {
sh "python -m build"
}
}
stage("test") {
steps {
sh "pip install dist/*.whl"
sh "filterfasta -h"
}
}
stage("archive") {
steps {
archiveArtifacts artifacts: 'dist/*.tar.gz, dist/*.whl', fingerprint: true, followSymlinks: false, onlyIfSuccessful: true
}
}
stage("publish") {
when {
branch '**/master'
}
steps {
withCredentials([usernamePassword(credentialsId: '4d6f64be-d26d-4f95-8de3-b6a9b0beb311', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh returnStatus: true, script: "python -m twine upload --repository-url https://git.reslate.systems/api/packages/${USER}/pypi -u ${USER} -p ${PASS} --non-interactive --disable-progress-bar --verbose dist/*"
}
}
}
}
}

10
environment.yml Normal file
View File

@@ -0,0 +1,10 @@
name: filterfasta
channels:
- conda-forge
dependencies:
- build=0.7
- pytest=7
- twine=4
- biopython=1.81
- python=3.11
prefix: ./env

View File

@@ -1,65 +0,0 @@
#!/usr/bin/env python3
import os
from Bio import SeqIO
import argparse
def main(args):
kept_records = []
for s_record in SeqIO.parse(args.input, "fasta"):
if args.property != "all" and not (
args.contains in getattr(s_record, args.property)
):
kept_records.append(s_record)
elif args.property == "all" and not (
args.contains in s_record.id
or args.contains in s_record.name
or args.contains in s_record.description):
kept_records.append(s_record)
SeqIO.write(
kept_records,
os.path.abspath(args.output),
"fasta"
)
if __name__ == "__main__":
argparser = argparse.ArgumentParser(
"Removes sequences where id contains certain string.")
argparser.add_argument(
"input",
type=str,
metavar="i",
help="The input fasta file."
)
argparser.add_argument(
"output",
type=str,
metavar="o",
help="The output file path."
)
argparser.add_argument(
"-c",
"--contains",
type=str,
default=None,
required=False,
help="The string to search for."
)
argparser.add_argument(
"-p",
"--property",
type=str,
default="all",
required=False,
help="""
The part of the fasta file to look through. Valid options are: id,
name, description, or all.
"""
)
main(argparser.parse_args())

0
filterfasta/__init__.py Normal file
View File

66
filterfasta/cli.py Executable file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env python3
import os
from Bio import SeqIO
import argparse
def filter(input: str, a_property: str, contains: str):
kept_records = []
for s_record in SeqIO.parse(input, "fasta"):
if a_property != "all" and not (contains in getattr(s_record, a_property)):
kept_records.append(s_record)
elif a_property == "all" and not (
contains in s_record.id
or contains in s_record.name
or contains in s_record.description
):
kept_records.append(s_record)
return kept_records
def write_to_fasta(kept_records, output: str):
SeqIO.write(kept_records, os.path.abspath(output), "fasta")
def run(args):
kept = filter(args.input, args.property, args.contains)
write_to_fasta(kept, args.output)
def main():
argparser = argparse.ArgumentParser(
"Removes sequences where id contains certain string."
)
argparser.add_argument("input", type=str, metavar="i", help="The input fasta file.")
argparser.add_argument(
"output", type=str, metavar="o", help="The output file path."
)
argparser.add_argument(
"-c",
"--contains",
type=str,
default=None,
required=False,
help="The string to search for.",
)
argparser.add_argument(
"-p",
"--property",
type=str,
default="all",
required=False,
help="""
The part of the fasta file to look through. Valid options are: 'id',
'name', 'description', or 'all'.
""",
)
args = argparser.parse_args()
run(args)
if __name__ == "__main__":
main()

3
pyproject.toml Normal file
View File

@@ -0,0 +1,3 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "wheel"]

View File

@@ -1 +1,5 @@
Bio==1.5.6
build
pytest
twine
biopython==1.81

10
setup.cfg Normal file
View File

@@ -0,0 +1,10 @@
[metadata]
name = filterfasta
version = 0.0.3
[options]
packages = filterfasta
[options.entry_points]
console_scripts =
filterfasta = filterfasta.cli:main

3
setup.py Normal file
View File

@@ -0,0 +1,3 @@
from setuptools import setup
setup()

3
tox.ini Normal file
View File

@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
extend-ignore = E203