Compare commits
11 Commits
5a034f59d2
...
master
Author | SHA1 | Date | |
---|---|---|---|
b94643d36b | |||
59f007873c | |||
6de659df58 | |||
bf357a5524 | |||
1b08cee027 | |||
c9bc645cc3 | |||
9dce2d26b6 | |||
953bb8f507 | |||
a6871214a4 | |||
6e6d7a6c43 | |||
43787805e0 |
22
.devcontainer/devcontainer.json
Normal file
22
.devcontainer/devcontainer.json
Normal 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
25
.gitignore
vendored
@@ -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
5
.vscode/launch.json
vendored
@@ -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
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"python.formatting.provider": "black"
|
||||
}
|
42
Jenkinsfile
vendored
Normal file
42
Jenkinsfile
vendored
Normal 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 returnStdout: 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
10
environment.yml
Normal 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
|
@@ -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
0
filterfasta/__init__.py
Normal file
66
filterfasta/cli.py
Executable file
66
filterfasta/cli.py
Executable 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
3
pyproject.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
[build-system]
|
||||
build-backend = "setuptools.build_meta"
|
||||
requires = ["setuptools", "wheel"]
|
@@ -1 +1,5 @@
|
||||
Bio==1.5.6
|
||||
build
|
||||
pytest
|
||||
twine
|
||||
biopython==1.81
|
10
setup.cfg
Normal file
10
setup.cfg
Normal file
@@ -0,0 +1,10 @@
|
||||
[metadata]
|
||||
name = filterfasta
|
||||
version = 0.0.3
|
||||
|
||||
[options]
|
||||
packages = filterfasta
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
filterfasta = filterfasta.cli:main
|
Reference in New Issue
Block a user