{"id":26573214,"url":"https://github.com/linsalrob/py_fasta_validator","last_synced_at":"2025-03-23T00:39:48.097Z","repository":{"id":62580279,"uuid":"270903677","full_name":"linsalrob/py_fasta_validator","owner":"linsalrob","description":"A Python extension of the fasta validator","archived":false,"fork":false,"pushed_at":"2023-02-05T05:33:22.000Z","size":77,"stargazers_count":7,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T16:56:42.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linsalrob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-09T04:37:34.000Z","updated_at":"2024-03-15T11:55:14.000Z","dependencies_parsed_at":"2023-02-18T22:00:40.386Z","dependency_job_id":null,"html_url":"https://github.com/linsalrob/py_fasta_validator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linsalrob%2Fpy_fasta_validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linsalrob%2Fpy_fasta_validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linsalrob%2Fpy_fasta_validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linsalrob%2Fpy_fasta_validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linsalrob","download_url":"https://codeload.github.com/linsalrob/py_fasta_validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245040190,"owners_count":20551299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-23T00:39:47.676Z","updated_at":"2025-03-23T00:39:48.083Z","avatar_url":"https://github.com/linsalrob.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Edwards Lab](https://img.shields.io/badge/Bioinformatics-EdwardsLab-03A9F4)](https://edwards.flinders.edu.au)\n[![DOI](https://www.zenodo.org/badge/270903677.svg)](https://www.zenodo.org/badge/latestdoi/270903677)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n![GitHub language count](https://img.shields.io/github/languages/count/linsalrob/py_fasta_validator)\n[![PyPi](https://img.shields.io/pypi/pyversions/py-fasta-validator.svg?style=flat-square\u0026label=PyPi%20Versions)](https://pypi.org/project/py-fasta-validator/)\n[![Anaconda-Server Badge](https://anaconda.org/bioconda/py_fasta_validator/badges/version.svg)](https://anaconda.org/bioconda/py_fasta_validator)\n\n# py_fasta_validator\n\nA Python extension of the [fasta validator](https://github.com/linsalrob/fasta_validator)\n\nThis is a Python C-extension to validate a fasta file. It only checks a few things, and by default only sets its response via the return code, so you will need to check that in your Python code. See the examples provided.\n\nThe simple rules that we adhere to are:\n\n1. Each header line starts with a `\u003e`. The header preceedes the sequence.\n2. Every other line is considered a sequence line\n3. Sequence lines may not contain whitespace, numbers, or non-sequence characters. In other words, they must only contain the characters [A-Z] and [a-z]\n4. Sequence lines can end with a new line or return depending on whether you have edited this file on a mac, pc, or linux machine.\n5. Sequence lines can be empty.\n6. The sequence identifier is the string of characters in the header line following the `\u003e` and upto the first whitespace. Everything after the first whitespace is descriptive, and can be as long as you like\n7. Each sequence identifier must be unique within the fasta file.\n\nWe will exit with the following return codes:\n\n* `0` this is a valid fasta file\n* `1` the first line does not start with a \u003e (rule 1 violated).\n* `2` there are duplicate sequence identifiers in the file (rule 7 violated)\n* `4` there are characters in a sequence line other than [A-Za-z]\n\nOther exit codes (e.g. 255, 254, etc) indicate internal errors in the program.\n\n# Running py_fasta_validator\n\nThe installation includes a command line application, `py_fasta_validator` that you can run. \n\n```bash\npy_fasta_validator -f file.fasta\n```\n\nor if the file is compressed with gzip:\n\n```bash\npy_fasta_validator -f file.fasta.gz\n```\n\n## As a python module\n\nYou can also import FastaValidator directly:\n\n```python\nimport FastaValidator\n\nreturn_code = FastaValidator.fasta_validator(file_name)\n```\n\n# Installation\n\n### Everyone\n\n_Recommended:_\n\nInstall with conda. This is the easiest way to install `py_fasta_validator` and the recommended method:\n\n```command-line\nconda install -c bioconda py_fasta_validator\n```\n\n_Alternate method:_\n\nInstall with pip:\n\n```\npip install py-fasta-validator\n```\n\n### Advanced\n\n#### Prerequisites\n\nIf you install using one the methods above you don't need to worry about the prerequistes, they are already included!\n\n[fasta validator](https://github.com/linsalrob/fasta_validator) is written in ANSI C but you will also need the Python developers toolkit (e.g. python-3.x-dev installed on your machine to provide Python.h)\n\n\nTo clone the code from GitHub use:\n\n```bash\ngit clone https://github.com/linsalrob/fasta_validator.git\ncd fasta_validator\n```\n\nTo build the code, use:\n\n```bash\nmake\n```\n\nThis should compile the source into an executable in the current working directory.\n\nPlease note, if you get an error like this:\n\n```\ngcc  -Wall -o fasta_validate ./fasta_validate.c -I/usr/include/python3.8 -I/usr/include/x86_64-linux-gnu/python3.8\n/usr/bin/ld: /tmp/ccgvrFaq.o: in function `python_input':\nfasta_validate.c:(.text+0x481): undefined reference to `PyArg_ParseTuple'\n/usr/bin/ld: fasta_validate.c:(.text+0x48c): undefined reference to `PyExc_RuntimeError'\n/usr/bin/ld: fasta_validate.c:(.text+0x49b): undefined reference to `PyErr_SetString'\n/usr/bin/ld: fasta_validate.c:(.text+0x4c3): undefined reference to `PyLong_FromLong'\n/usr/bin/ld: /tmp/ccgvrFaq.o: in function `PyInit_fastaValidator':\nfasta_validate.c:(.text+0x4f2): undefined reference to `PyModule_Create2'\ncollect2: error: ld returned 1 exit status\nmake: *** [Makefile:9: all] Error 1\n```\n\nThen we need to append the version of python to the `make` command. I am (currently) running `python3.8` and the command to compile without error is:\n\n```\nmake CFLAGS=-lpython3.8\n```\n\n\u003csmall\u003eI don't know the exact cause of this error, but `pkg-config --libs python3` is not reporting anything when it should report `-lpython3.8`\u003c/small\u003e\n\nTo install this code as root (sudo) you can use:\n\n```bash\nmake install\n```\n\nand this will copy the executable to `/usr/local/bin`.\n\nto install it as a user, just copy the compiled binary `fasta_validate` to somewhere on your path.\n\n\n# Testing\n\nTo test the code you can use the example data provided. Download the [test data set](https://github.com/linsalrob/py_fasta_validator/raw/master/test.zip) [zip file, 16.4 kb] and uncompress it.\n\n```command-line\n$ for FASTA in test/*fasta test/*fasta.gz; do echo $FASTA; py_fasta_validator -f $FASTA; echo \"Exit code: $?\"; done\n```\n\nThis will output the name of the fasta file, the output, and the exit code from the process:\n\n```command-line\ntest/code.fasta\ntest/code.fasta has non-sequence characters in it\nExit code: 4\ntest/duplicates_no_spaces.fasta\ntest/duplicates_no_spaces.fasta has multiple sequences with the same identifier\nExit code: 2\ntest/duplicates_with_spaces.fasta\ntest/duplicates_with_spaces.fasta has multiple sequences with the same identifier\nExit code: 2\ntest/good.fasta\nExit code: 0\ntest/good_mixed.fasta\nExit code: 0\ntest/good_multiline.fasta\nExit code: 0\ntest/no_first_line.fasta\ntest/no_first_line.fasta does not start with a \u003e\nExit code: 1\ntest/space.fasta\ntest/space.fasta has non-sequence characters in it\nExit code: 4\ntest/code.fasta.gz\ntest/code.fasta.gz has non-sequence characters in it\nExit code: 4\ntest/duplicates_no_spaces.fasta.gz\ntest/duplicates_no_spaces.fasta.gz has multiple sequences with the same identifier\nExit code: 2\ntest/duplicates_with_spaces.fasta.gz\ntest/duplicates_with_spaces.fasta.gz has multiple sequences with the same identifier\nExit code: 2\ntest/good.fasta.gz\nExit code: 0\ntest/good_mixed.fasta.gz\nExit code: 0\ntest/good_multiline.fasta.gz\nExit code: 0\ntest/no_first_line.fasta.gz\ntest/no_first_line.fasta.gz does not start with a \u003e\nExit code: 1\ntest/space.fasta.gz\ntest/space.fasta.gz has non-sequence characters in it\nExit code: 4\n```\n\n\n# Developing/Testing\n\nNote, if you are developing and testing in a conda environment, you might run into an error like:\n\n```\n./fasta_validate: error while loading shared libraries: libpython3.11.so.1.0: cannot open shared object file: No such file or directory\n```\n\nYou need to make sure that `LD_LIBRARY_PATH` is set to your `/lib/` in your conda environment.\n\nFor example:\n\n```bash\n$ ./fasta_validate\n./fasta_validate: error while loading shared libraries: libpython3.11.so.1.0: cannot open shared object file: No such file or directory\n$ mamba install -y python-devtools\n$ which python\n~/miniconda3/envs/py_fasta/bin/python\n$ export LD_LIBRARY_PATH_OLD=$LD_LIBRARY_PATH # make a back up of the original LD_LIBRARY_PATH, just in case!\n$ export LD_LIBRARY_PATH=$HOME/miniconda3/envs/py_fasta/lib/:$LD_LIBRARY_PATH # set the new library path\n$ ./fasta_validate \n./fasta_validate [-v] [fasta file]\n```\n\nNote: to make this change permanent you should set the `$LD_LIBRARY_PATH` variable (and the copy) in `etc/conda/activate.d/env_vars.sh` and `etc/conda/deactivate.d/env_vars.sh` as [described in the docs](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#macos-and-linux)\n\n\n# Citation\n\nPlease cite this as \n\nEdwards, R.A. 2019. fasta_validate: a fast and efficient fasta validator written in pure C. DOI: 10.5281/zenodo.2532044\n[![DOI](https://zenodo.org/badge/164130774.svg)](https://zenodo.org/badge/latestdoi/164130774)\n\n# What is the difference between this and [fasta_validator](https://github.com/linsalrob/fasta_validator)?\n\nNot very much!\n\nThe original C code was written for the [Search SRA](https://searchsra.org/) project as we wanted to validate fasta files uploaded by users. That code is written in C, and does not require any additional libraries to install.\n\nThis version adds the Python hooks, and so it requires the Python development library to be installed. Therefore, we kept them as two separate projects, although you'll notice the C code is essentially the same!\n\n# License\n\nThis software is released using the [MIT License](LICENSE)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinsalrob%2Fpy_fasta_validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinsalrob%2Fpy_fasta_validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinsalrob%2Fpy_fasta_validator/lists"}