{"id":20483316,"url":"https://github.com/styczynski/aadg-genomics-class","last_synced_at":"2026-04-24T05:34:31.145Z","repository":{"id":211887340,"uuid":"729512695","full_name":"styczynski/aadg-genomics-class","owner":"styczynski","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-15T22:42:28.000Z","size":6225,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-05T16:16:20.299Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/styczynski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-09T13:20:11.000Z","updated_at":"2024-12-15T22:42:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"3018a46c-6eaa-40c7-9a8f-19cc67956260","html_url":"https://github.com/styczynski/aadg-genomics-class","commit_stats":null,"previous_names":["styczynski/aadg-genomics-class"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/styczynski/aadg-genomics-class","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Faadg-genomics-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Faadg-genomics-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Faadg-genomics-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Faadg-genomics-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/styczynski","download_url":"https://codeload.github.com/styczynski/aadg-genomics-class/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Faadg-genomics-class/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32211341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T03:15:14.334Z","status":"ssl_error","status_checked_at":"2026-04-24T03:15:11.608Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2024-11-15T16:16:56.529Z","updated_at":"2026-04-24T05:34:31.118Z","avatar_url":"https://github.com/styczynski.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Algorithms for genomic data analysis (Assignment 1)\n*Winter semester 2023/2024*\n**Simple sequence aligner written in pure Python**\n\n## Task defition\n\nImplement a read mapping algorithm that\n\n- is designed to work on reads of `length∼ 1 kbp` with error rate `5 − 10%`,\n- may fail to map some reads, but cannot return incorrect alignments,\n- is efficient (i.e. fast) and has good quality (i.e. high proportion of mapped reads).\n\nIn your program you can use:\n- the codes from the classes,\n- libraries included in standard Python distribution, as well as NumPy, SciPy and Biopython,\n- available code for building suffix arrays or similar structures (e.g. the attached implementation of the\n    Karkkainen-Sanders algorithm).\n\nIn your program you cannot use:\n- programs and libraries to read assembly, mapping, alignment, etc.\n- multiprocessing commands,\n- subprograms written in other languages.\n\nThe solution should include:\n- program file written in Python 3,\n- slides with short description of your approach.\n\n### Specification and attached files\n\nMinimum performance requirements are following:\n- Given the reference sequence of `length≤20 Mbp`, a collection\nof rreads should be processed in at most `2+r/10 minutes` and `memory\u003c1GB`, resulting\nin `≥80%` reads mapped and no read mapped incorrectly.\n\nProgram should be executable using syntax:\n`python3 mapper.py reference.fasta reads.fasta output.txt`\n\nInput data are in fasta format. Output file should consist of one line for each mapped read, consisting of read\nidentifier, start and end positions of read alignment, separated by tabs.\n\nIt can be assumed that all reads come from the reference sequence, but contain errors (substitutions, in-\nsertions and deletions of single nucleotides) resulting from the sequencing process. Errors occur independently\nat each position at the assumed error rate, so the total number of errors may slightly exceed10%of the read\nlength. A read is mapped correctly when the mapping coordinates differ from the actual coordinates of the\nfragment it comes from by `≤20 bp`.\n\n## Solution\n\n### Running the aligner\n\nThe solution uses [Poetry as a package manager](https://python-poetry.org/docs/), logging with custom colouring and other non-computation-specific utility libraries.\nThe entry script should install Poetry by default when you run it via the original syntax i.e.:\n```bash\n    python3 mapper.py data/reference.fasta data/reads0.fasta output.txt\n```\n\nIn case the script fails to install [Poetry](https://python-poetry.org/docs/) (note that this was tested on the university server already), you can manually install dependencies and run the script:\n```bash\n    # Install poetry\n    $ pipx install poetry\n    # Install dependencies\n    $ poetry install\n    # Run the aligner\n    $ poetry run aadg_genomics_class/cli.py data/reference.fasta data/reads0.fasta output.txt\n```\n\nYou can pass additional parameters to the aligner. Please use `--help` parameter to display help information:\n```bash\n    $ python3 mapper.py --help\n    # or alternative syntax:\n    $ poetry run aadg_genomics_class/cli.py --help\n```\n\nThis is how the help looks like:\n```\nUsage: cli.py \u003ctarget_fasta\u003e \u003cquery_fasta\u003e [\u003coutput\u003e] [OPTIONS]\n\nArguments:\n  target-fasta: \u003ctarget_fasta\u003e  Target sequence FASTA file path  [required]\n  query-fasta: \u003cquery_fasta\u003e    Query sequences FASTA file path  [required]\n  output: [\u003coutput\u003e]            Output file path  [default: output.txt]\n\n[OPTIONS]:\n  --kmer-len INTEGER        [default: 15]\n  --window-len INTEGER      [default: 5]\n  --f FLOAT                 Portion of top frequent kmers to be removed from\n                            the index (must be in range 0 to 1 inclusive)\n                            [default: 0.001]\n  --score-match INTEGER     [default: 1]\n  --score-mismatch INTEGER  [default: 1]\n  --score-gap INTEGER       [default: 1]\n  -h, --help                Show this message and exit.\n```\n\nThe full program usage can look like this:\n\n![CLI usage screenshot](https://github.com/styczynski/aadg-genomics-class/blob/main/static/screen0.png?raw=true)\n\n\n### Alignment algorithms introduction\n\nSequence alignment is a transformative process that elucidates the steps required to derive one sequence from another. In the realm of bioinformatics, its primary application lies in identifying analogous segments within DNA chains, RNA chains, or proteins to unveil evolutionary and functional associations. The approach commonly employed for such alignments is dynamic programming, a methodology that resolves intricate problems by dissecting them into smaller, recursive subproblems. The outcomes of these subproblems are stored and utilized to reconstruct the ultimate solution.\n\nVarious versions of pairwise alignment algorithms exist, such as the Needleman-Wunsch algorithm for global alignment, the Smith-Waterman algorithm for local alignment, and semi-global algorithms tailored for suffix-prefix and prefix-suffix alignments. Distinctions among them primarily lie in the initialization step and the starting point for the backtrack procedure.\n\nGiven the quadratic time complexity of alignment algorithms, the expedited detection of similar regions between sequences often employs k-mer indexing. However, the comprehensive collection of all k-mers can strain computational resources, particularly when targeting frequently occurring k-mers in the sequence set. Focusing on a subset of k-mers can mitigate these challenges while maintaining a reasonable level of sensitivity.\n\nOne such approach involves leveraging lexicographically smallest k-mers known as minimizers, [as detailed here](https://academic.oup.com/bioinformatics/article/20/18/3363/202143).\n\n### High-level algorithm of the aligner\n\n**The current implemenation works (on the highest-level) somewhere like this:**\n\n1. Load all target and query sequences and covert them to numpy arrays\n2. I build a minimizer index from the target sequence, which will store all positions and origins for each distinct minimizer found in the reference\n3. Ignore too frequent minimizers should (controlled by parameter) in that target index\n4. For each query\n    1. Build a minimizer index for that sequence\n    2. All minimizers of a query are to be searched against the reference index to find matches. From the list of all matches for a pair of (query, reference), the longest linear chain should represent the best candidate for a good alignment between the pair. That region can be obtained in quasilinear time by solving the longest increasing subsequence problem on the list of minimizer matches.\n    3. I invoke aligner (Needleman-Wunsch) only on the found regions\n    4. I print matched regions with correct position paddings\n5. Print summary reports\n\n### Other resources\n\nPlease see [uploaded assignment presentation draft here](https://github.com/styczynski/aadg-genomics-class/blob/main/static/AADG_Assignment_1.pdf)\n\n\npdflatex source.tex --shell-escape --enable-pipes --enable-write18","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyczynski%2Faadg-genomics-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstyczynski%2Faadg-genomics-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyczynski%2Faadg-genomics-class/lists"}