def to_graph(alnfname, weight_func):
import networkx<EOL>G = networkx.Graph()<EOL>aln = AlignIO.read(alnfname, '<STR_LIT>')<EOL>for i, arec in enumerate(aln):<EOL><INDENT>for brec in aln[i+<NUM_LIT:1>:]:<EOL><INDENT>ident = weight_func(str(arec.seq), str(brec.seq))<EOL>G.add_edge(arec.id, brec.id, weight=ident)<EOL><DEDENT><DEDENT>return G<EOL>
Create a NetworkX graph from a sequence alignment.

    Nodes are string sequence IDs; edge weights are the output of weight_func
    between each pair, by default the absolute identity (# identical chars).