PICASO.link_clustering ====================== .. py:module:: PICASO.link_clustering .. autoapi-nested-parse:: changes 2010-08-27: * all three output files now contain the same community id numbers * comm2nodes and comm2edges both present the cid as the first entry of each line. Previously only comm2nodes did this. * implemented weighted version, added '-w' switch * expanded help string to explain input and outputs changes 2021-02-05: * Support Python 3.x Classes ------- .. autoapisummary:: PICASO.link_clustering.HLC PICASO.link_clustering.MyParser Functions --------- .. autoapisummary:: PICASO.link_clustering.swap PICASO.link_clustering.Dc PICASO.link_clustering.similarities_unweighted PICASO.link_clustering.similarities_weighted PICASO.link_clustering.read_edgelist_unweighted PICASO.link_clustering.read_edgelist_weighted PICASO.link_clustering.write_edge2cid PICASO.link_clustering.write_dendro Module Contents --------------- .. py:function:: swap(a, b) .. py:function:: Dc(m, n) partition density .. py:class:: HLC(adj, edges) .. py:attribute:: adj .. py:attribute:: edges .. py:attribute:: Mfactor .. py:attribute:: edge2cid .. py:attribute:: orig_cid2edge .. py:attribute:: curr_maxcid :value: 0 .. py:attribute:: linkage :value: [] .. py:attribute:: D :value: 0.0 .. py:method:: initialize_edges() .. py:method:: merge_comms(edge1, edge2, S, dendro_flag=False) .. py:method:: single_linkage(threshold=None, w=None, dendro_flag=False) .. py:function:: similarities_unweighted(adj) Get all the edge similarities. Input dict maps nodes to sets of neighbors. Output is a list of decorated edge-pairs, (1-sim,eij,eik), ordered by similarity. .. py:function:: similarities_weighted(adj, ij2wij) Same as similarities_unweighted but using tanimoto coefficient. `adj' is a dict mapping nodes to sets of neighbors, ij2wij is a dict mapping an edge (ni,nj) tuple to the weight wij of that edge. .. py:function:: read_edgelist_unweighted(filename, delimiter=None, nodetype=str) reads two-column edgelist, returns dictionary mapping node -> set of neighbors and a list of edges .. py:function:: read_edgelist_weighted(filename, delimiter=None, nodetype=str, weighttype=float) same as read_edgelist_unweighted except the input file now has three columns: node_inode_jweight_ij and the output includes a dict `ij2wij' mapping edge tuple (i,j) to w_ij .. py:function:: write_edge2cid(e2c, filename, delimiter='\t') writes the .edge2comm, .comm2edges, and .comm2nodes files .. py:function:: write_dendro(filename, orig_cid2edge, linkage) .. py:class:: MyParser(usage=None, option_list=None, option_class=Option, version=None, conflict_handler='error', description=None, formatter=None, add_help_option=True, prog=None, epilog=None) Bases: :py:obj:`optparse.OptionParser` Class attributes: standard_option_list : [Option] list of standard options that will be accepted by all instances of this parser class (intended to be overridden by subclasses). Instance attributes: usage : string a usage string for your program. Before it is displayed to the user, "%prog" will be expanded to the name of your program (self.prog or os.path.basename(sys.argv[0])). prog : string the name of the current program (to override os.path.basename(sys.argv[0])). description : string A paragraph of text giving a brief overview of your program. optparse reformats this paragraph to fit the current terminal width and prints it when the user requests help (after usage, but before the list of options). epilog : string paragraph of help text to print after option help option_groups : [OptionGroup] list of option groups in this parser (option groups are irrelevant for parsing the command-line, but very useful for generating help) allow_interspersed_args : bool = true if true, positional arguments may be interspersed with options. Assuming -a and -b each take a single argument, the command-line -ablah foo bar -bboo baz will be interpreted the same as -ablah -bboo -- foo bar baz If this flag were false, that command line would be interpreted as -ablah -- foo bar -bboo baz -- ie. we stop processing options as soon as we see the first non-option argument. (This is the tradition followed by Python's getopt module, Perl's Getopt::Std, and other argument- parsing libraries, but it is generally annoying to users.) process_default_values : bool = true if true, option default values are processed similarly to option values from the command line: that is, they are passed to the type-checking function for the option's type (as long as the default value is a string). (This really only matters if you have defined custom types; see SF bug #955889.) Set it to false to restore the behaviour of Optik 1.4.1 and earlier. rargs : [string] the argument list currently being parsed. Only set when parse_args() is active, and continually trimmed down as we consume arguments. Mainly there for the benefit of callback options. largs : [string] the list of leftover arguments that we have skipped while parsing options. If allow_interspersed_args is false, this list is always empty. values : Values the set of option values currently being accumulated. Only set when parse_args() is active. Also mainly for callbacks. Because of the 'rargs', 'largs', and 'values' attributes, OptionParser is not thread-safe. If, for some perverse reason, you need to parse command-line arguments simultaneously in different threads, use different OptionParser instances. .. py:method:: format_epilog(formatter)