Building a contig-level graph from a Flye assembly graph
Flye writes an assembly graph whose segments are graph edges (edge_X), not the contigs (contig_X) in assembly.fasta. The contigger merges chains of edges into single contigs, so the graph holds more segments than the assembly holds contigs, under different names. Tools that read S records and expect one per contig get the wrong answer (see dnaapler#105).
flye2contig reads the P records, which record the oriented edges each contig walks through, and writes a GFA with one S record per contig of assembly.fasta and L records lifted from the edge-level links.
Note
Only Flye assemblies are supported for now.
Usage
agtools flye2contig -g assembly_graph.gfa -f assembly.fasta -i assembly_info.txt -o contig_graph.gfa
-g— Flyeassembly_graph.gfa-f— Flyeassembly.fasta, required; contig sequences cannot be rebuilt from the graph alone-i— Flyeassembly_info.txt, optional; supplies coverage and circularity
Example
Consider the following GFA file with five edges: edge_1 on its own, edge_2 a self-loop, and edge_3 branching into edge_4 and edge_5.
H VN:Z:1.0
S edge_1 AAAACCCC dp:i:20
S edge_2 ACGTACGT dp:i:30
S edge_3 GGGGTTTT dp:i:40
S edge_4 TTTTAAAA dp:i:35
S edge_5 CCCCGGGG dp:i:4
L edge_2 + edge_2 + 0M
L edge_3 + edge_4 + 0M
L edge_3 + edge_5 + 0M
P contig_1 edge_1+ *
P contig_2 edge_2+ *
P contig_3 edge_3+,edge_4+ *
It will look as below.

The assembly.fasta file will look as follows. Assume that Flye resolved the branch through edge_4, the higher-coverage side, so assembly.fasta has no contig_4.
>contig_1
AAAACCCC
>contig_2
ACGTACGT
>contig_3
GGGGTTTTTTTTAAAA
The assembly_info.txt file will look as follows.
#seq_name length cov. circ. repeat mult. alt_group graph_path
contig_1 8 20 N N 1 * 1
contig_2 8 30 Y N 1 * 2
contig_3 16 38 N N 1 * 3,4
flye2contig will produce the following GFA file.
H VN:Z:1.0
S contig_1 AAAACCCC LN:i:8 dp:i:20 TP:Z:linear
S contig_2 ACGTACGT LN:i:8 dp:i:30 TP:Z:circular
S contig_3 GGGGTTTTTTTTAAAA LN:i:16 dp:i:38 TP:Z:linear
L contig_2 + contig_2 + 0M
It will look as below.

contig_2keeps its self-link, which is how a circular contig is represented in GFA.contig_3spansedge_3andedge_4, so that link is interior to the contig and is not lifted. Only adjacencies at the ends of a path becomeLrecords.edge_4is dropped, sinceassembly.fastahas no such contig containing it, and theedge_3/edge_5link goes with it.
Segment tags
assembly_info.txt is optional, so the tags on each S record depend on whether you pass -i.
| Tag | Meaning | Written when |
|---|---|---|
LN:i: |
Sequence length | always |
dp:i: |
Read coverage, from the cov. column of assembly_info.txt |
only with -i |
TP:Z: |
circular or linear, from the circ. column of assembly_info.txt |
only with -i |
Without -i, segments carry LN:i: alone and the links are unchanged.
Warning
A self-link does not on its own mean a contig is circular — a repeat contig whose two ends are adjacent in the graph carries one too. Use the TP:Z: tag.
Link overlaps are copied from the edge-level links, always 0M in a Flye graph. For contigs that Flye extended into flanking repeats the junction is not exactly flush, so treat the overlap as nominal.