{"id":16713144,"url":"https://github.com/adamtaranto/graphtagger","last_synced_at":"2026-01-22T05:33:30.570Z","repository":{"id":217261158,"uuid":"742689526","full_name":"Adamtaranto/GraphTagger","owner":"Adamtaranto","description":"Small script to compute coverage of contigs from reads","archived":false,"fork":false,"pushed_at":"2024-11-03T06:34:30.000Z","size":94,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-08T23:52:28.940Z","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":"RolandFaure/compute_coverage","license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Adamtaranto.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-13T04:22:05.000Z","updated_at":"2024-11-23T09:41:05.000Z","dependencies_parsed_at":"2024-11-21T02:33:08.016Z","dependency_job_id":"7b69f46f-43e3-4e0d-bae5-f4e3dae78cb4","html_url":"https://github.com/Adamtaranto/GraphTagger","commit_stats":null,"previous_names":["adamtaranto/graphtagger"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Adamtaranto/GraphTagger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adamtaranto%2FGraphTagger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adamtaranto%2FGraphTagger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adamtaranto%2FGraphTagger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adamtaranto%2FGraphTagger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Adamtaranto","download_url":"https://codeload.github.com/Adamtaranto/GraphTagger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adamtaranto%2FGraphTagger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28656289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-10-12T20:45:39.045Z","updated_at":"2026-01-22T05:33:30.556Z","avatar_url":"https://github.com/Adamtaranto.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphTagger\nCollection of python tools to edit tags in assembly graph (.gfa) files. \n\nSequences in GFA files are called Segments and may have meta-data stored in tags with the format `TAG:TYPE:VALUE`. See the [GFA-Spec](https://gfa-spec.github.io/GFA-spec/).\n\n\nFor example, mean read depth of 100 stored as a float would be: `DP:f:100`. You can use `csv2tag` to add or update arbritrary tags.\n\n**New features**\n\nGot an tag related task in need of automation? [Suggest a feature](https://github.com/Adamtaranto/GraphTagger/issues).\n\n## Installation\n\nGraphTagger requires Python \u003e= v3.8\n\nInstall directly from this git repository.\n\n```bash\npip install git+https://github.com/Adamtaranto/GraphTagger.git\n```\n\nOr clone and install locally.\n\n```bash\ngit clone https://github.com/Adamtaranto/GraphTagger.git \u0026\u0026 cd GraphTagger\npip install -e .\n```\n\n## Tools \n\n### Tools for updating segment tags\n\n**csv2tag**: Adds or updates gfa segment tags from a CSV. \nCSV lines have the format `Name`,`Tag`,`Type`,`Value`.\n\n**map2tag**: Uses Minimap2 to map reads to the assembly and approximates the coverage of each contig. Updates the `DP` depth tag.\n\n### Working with Paths\n[DEV] **gaf2path**: Generate GFA format Path lines from GraphAligner GAF output.\n\n### Feature annotation tools\n\n**tel2bed**: Quick annotation of telomeric repeat runs in FASTA file, outputs BED format. This is useful for visualising potential chromosome ends in [Bandage-NG](https://github.com/asl/BandageNG). \n\n### Converting between GFA and FASTA\n\n#### Converting from FASTA to GFA\n\n**fa2gfa**: Convert FASTA to GFA format. Produces Segment records for each FASTA record. Adds `LN` tags.\n\n#### Converting from GFA to FASTA\n\nTo convert an assembly graph into a FASTA of contigs you can use one of these `awk` one-liners.\n\nIf you want to preserve the GFA segment tags (i.e. segment length `LN`, or depth `DP`) in the FASTA description, option #2 will append them to the FASTA headers.\n\n```bash\n# Convert GFA to FASTA\n# Supports sequence names longer than the 80 char sequence wrap length.\nawk '/^S/{print \"\u003e\"$2; printf \"%s\", $3 | \"fold -w 80\"; close(\"fold -w 80\"); print \"\"}' in.gfa \u003e out.fa\n\n# Include GFA tags in FASTA header line.\nawk '/^S/{header=\"\u003e\"$2; for(i=4; i\u003c=NF; i++) {header=header\" \"$i}; print header; printf \"%s\", $3 | \"fold -w 80\"; close(\"fold -w 80\"); print \"\"}' in.gfa \u003e out.fa\n```\n\n## Usage\n\n### csv2tag\n\nAdd tags to GFA from csv file.\n\nINPUT_GFA: Path to the input GFA file (can be gzipped).   \nINPUT_CSV: Must have format = [NAME,TAG,TYPE,VALUE]   \nOUTPUT_GFA: Write updated GFA to this file.   \n\nOptions:\n\n- --preserve_tags:   \nIf set, preserve pre-existing tags from gfa file.\n\n- --calc_len:        \nIf set, calculate new LN tags from length of sequence.\n\n- --calc_hash:\nIf set, calculate new SH tag as sha256 hash of sequence.\n\n- --strict\nIf set, only return tags that comply with the GFA 1.0 spec\n\n```bash\ncsv2tag -i input.gfa -c new_tags.csv -o output.gfa\n```\n\n### map2tag\n\nApproximate coverage from mapped long reads.   \n\n```bash\nmap2tag -i input.gfa -r nanopore_reads.fq.gz -p outdir/tagged_graph -t 4 -x map-ont\n# Output: outdir/tagged_graph.gfa\n```\n### gaf2path\n\nConvert graph-alignments (GAF) to GFA path-lines. Only reports paths that have at least 2 segments.\n\nINPUT_GAF: GAF file containing path information. Produced by [GraphAligner](https://github.com/maickrau/GraphAligner).   \n\nOUTPUT_GFA: GFA formatted path-lines. Can be manually appended to the end of the original GFA graph used to produce the GAF file.\n\n```bash\n# Align long-reads to GFA \nGraphAligner --threads 8 --multimap-score-fraction 1 -x vg -f reads.fq -g input_graph.gfa -a longreads_aligned_on_gfa.gaf\n\n# Convert GAF to GFA path-lines\ngaf2path -g longreads_aligned_on_gfa.gaf -o pathlines.gfa\n\n# Append pathlines to end of original graph\ncat pathlines.gfa \u003e\u003e input_graph.gfa\n```\n\n### fa2gfa\n\nConvert a FASTA file to GFA format.\n\nINPUT_FASTA: Path to the input FASTA file (can be gzipped).\n\nOUTPUT_GFA: Path to the output GFA file. If not provided, the output will be same as input but with the '.gfa' extension.\n\n```bash\nfa2gfa -i assembly.fa.gz -o output assembly.gfa\n```\n\n### tel2bed\n\nQuick annotation of telomeric repeat runs in fasta file.\n\nINPUT_FASTA: Path to the input FASTA file (can be gzipped).\n\nOptions:\n\n- -o,--output_bed:  \nPath to the output BED file. If not provided, the output file will have the same basename as the input with the '.bed' extension.\n- -m,--motif:  \nTelomeric motif to annotate in genome. By default tel2bed will search in fwd and rev orientations and will allow +/- 1bp flexibility in the pattern at any polynucleotide run.\n\n- -r,--min_repeats:   \nMinimum number of sequential pattern matches required for a hit to be reported. Default: 3\n\n```bash\ntel2bed -i contigs.fa -m TTAGGG -r 3\n```\n\n## Example: Add depth tags from MosDepth.\n\nConvert [MosDepth](https://github.com/brentp/mosdepth) summary.txt file into CSV and use csv2tag to update `DP` tags in a corresponding `GFA`.\n\n\n```bash\nMINIASM_FASTA=\"path/to/miniasm_assembly.fa\"\nTEMP=/tmp\n\n# Index asm\nbwa-mem2 index -p minasm_idx $MINIASM_FASTA\n\n# Map illumina data to asm\n# Use smart pairing option -p to pass paired and unpaired reads\n(seqtk mergepe paired_R?.fastq.gz; zcat unpaired.fastq.gz) | bwa-mem2 mem -p -t 8 -o aligned_reads.sam minasm_idx -\n\n# Sort and write to bam\nsamtools view -u aligned_reads.sam | samtools sort -@ 8 -T $TEMP -o aligned_reads.sorted.bam \n# Delete sam\nrm aligned_reads.sam \n\n# Index the sorted bam\nsamtools index -@ 8 aligned_reads.sorted.bam\n\n# Calc median depth\nmkdir mosdepth\nmosdepth -t 8 --use-median --no-per-base -F 1796 --by 500 mosdepth/miniasm-asm aligned_reads.sorted.bam \n```\n\nInspect the mosdepth summary file.\n\n```bash\ncat mosdepth/miniasm-asm.mosdepth.summary.txt \n```\n\noutput:\n```\nchrom\tlength\tbases\tmean\tmin\tmax\nutg000001l\t1258785\t128682030\t102.23\t0\t422\nutg000001l_region\t1258785\t128682030\t102.23\t0\t422\nutg000002l\t1176747\t122097652\t103.76\t0\t314\nutg000002l_region\t1176747\t122097652\t103.76\t0\t314\nutg000003l\t872965\t88294465\t101.14\t0\t434\nutg000003l_region\t872965\t88294465\t101.14\t0\t434\nutg000004c\t81755\t115821276\t1416.69\t0\t3204\nutg000004c_region\t81755\t115821276\t1416.69\t0\t3204\n...\ntotal\t34741114\t3752939904\t108.03\t0\t15782\ntotal_region\t34741114\t3752939904\t108.03\t0\t15782\n```\n\nConvert the `*.mosdepth.summary.txt` file to CSV\n```bash\n# Exclude lines that begin with \"chrom   length\" or \"total\"\n# Exclude lines that contain \"region\"\n# Write NAME,TAG,TYPE,VALUE in comma delimited format\nawk -F'\\t' 'BEGIN {OFS=\",\"} !/^chrom\\tlength|^total|region/ {print $1, \"DP\", \"f\", $4}' mosdepth/miniasm-asm.mosdepth.summary.txt \u003e new_tags.csv\n```\n\nUpdate tags with csv2tag\n\n```bash\ncsv2tag -i miniasm_assembly.gfa -c new_tags.csv -o miniasm_assembly_with_tags.gfa\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamtaranto%2Fgraphtagger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamtaranto%2Fgraphtagger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamtaranto%2Fgraphtagger/lists"}