idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
56,000 | def from_der_private_key ( data : bytes , password : Optional [ str ] = None ) -> _RSAPrivateKey : return serialization . load_der_private_key ( data , password , default_backend ( ) ) | Convert private key in DER encoding to a Private key object |
56,001 | async def get_object ( self , Bucket : str , Key : str , ** kwargs ) -> dict : if self . _s3_client is None : await self . setup ( ) _range = kwargs . get ( 'Range' ) actual_range_start = None desired_range_start = None desired_range_end = None if _range : range_match = RANGE_REGEX . match ( _range ) if not range_match : raise ValueError ( 'Dont understand this range value {0}' . format ( _range ) ) desired_range_start = int ( range_match . group ( 1 ) ) desired_range_end = range_match . group ( 2 ) if desired_range_end is None : desired_range_end = 9223372036854775806 else : desired_range_end = int ( desired_range_end ) actual_range_start , actual_range_end = _get_adjusted_crypto_range ( desired_range_start , desired_range_end ) kwargs [ 'Range' ] = 'bytes={0}-{1}' . format ( actual_range_start , actual_range_end ) s3_response = await self . _s3_client . get_object ( Bucket = Bucket , Key = Key , ** kwargs ) file_data = await s3_response [ 'Body' ] . read ( ) metadata = s3_response [ 'Metadata' ] whole_file_length = int ( s3_response [ 'ResponseMetadata' ] [ 'HTTPHeaders' ] [ 'content-length' ] ) if 'x-amz-key' not in metadata and 'x-amz-key-v2' not in metadata : return s3_response if 'x-amz-key' in metadata : body = await self . _decrypt_v1 ( file_data , metadata , actual_range_start ) else : body = await self . _decrypt_v2 ( file_data , metadata , whole_file_length , actual_range_start , desired_range_start , desired_range_end ) s3_response [ 'Body' ] = DummyAIOFile ( body ) return s3_response | S3 GetObject . Takes same args as Boto3 documentation |
56,002 | async def put_object ( self , Body : Union [ bytes , IO ] , Bucket : str , Key : str , Metadata : Dict = None , ** kwargs ) : if self . _s3_client is None : await self . setup ( ) if hasattr ( Body , 'read' ) : if inspect . iscoroutinefunction ( Body . read ) : Body = await Body . read ( ) else : Body = Body . read ( ) is_kms = isinstance ( self . _crypto_context , KMSCryptoContext ) authenticated_crypto = is_kms and self . _crypto_context . authenticated_encryption Metadata = Metadata if Metadata is not None else { } aes_key , matdesc_metadata , key_metadata = await self . _crypto_context . get_encryption_aes_key ( ) if is_kms and authenticated_crypto : Metadata [ 'x-amz-cek-alg' ] = 'AES/GCM/NoPadding' Metadata [ 'x-amz-tag-len' ] = str ( AES_BLOCK_SIZE ) iv = os . urandom ( 12 ) aesgcm = AESGCM ( aes_key ) result = await self . _loop . run_in_executor ( None , lambda : aesgcm . encrypt ( iv , Body , None ) ) else : if is_kms : Metadata [ 'x-amz-cek-alg' ] = 'AES/CBC/PKCS5Padding' iv = os . urandom ( 16 ) padder = PKCS7 ( AES . block_size ) . padder ( ) padded_result = await self . _loop . run_in_executor ( None , lambda : ( padder . update ( Body ) + padder . finalize ( ) ) ) aescbc = Cipher ( AES ( aes_key ) , CBC ( iv ) , backend = self . _backend ) . encryptor ( ) result = await self . _loop . run_in_executor ( None , lambda : ( aescbc . update ( padded_result ) + aescbc . finalize ( ) ) ) Metadata [ 'x-amz-unencrypted-content-length' ] = str ( len ( Body ) ) Metadata [ 'x-amz-iv' ] = base64 . b64encode ( iv ) . decode ( ) Metadata [ 'x-amz-matdesc' ] = json . dumps ( matdesc_metadata ) if is_kms : Metadata [ 'x-amz-wrap-alg' ] = 'kms' Metadata [ 'x-amz-key-v2' ] = key_metadata else : Metadata [ 'x-amz-key' ] = key_metadata await self . _s3_client . put_object ( Bucket = Bucket , Key = Key , Body = result , Metadata = Metadata , ** kwargs ) | PutObject . Takes same args as Boto3 documentation |
56,003 | def histogram1d ( x , bins , range , weights = None ) : nx = bins if not np . isscalar ( bins ) : raise TypeError ( 'bins should be an integer' ) xmin , xmax = range if not np . isfinite ( xmin ) : raise ValueError ( "xmin should be finite" ) if not np . isfinite ( xmax ) : raise ValueError ( "xmax should be finite" ) if xmax <= xmin : raise ValueError ( "xmax should be greater than xmin" ) if nx <= 0 : raise ValueError ( "nx should be strictly positive" ) if weights is None : return _histogram1d ( x , nx , xmin , xmax ) else : return _histogram1d_weighted ( x , weights , nx , xmin , xmax ) | Compute a 1D histogram assuming equally spaced bins . |
56,004 | def histogram2d ( x , y , bins , range , weights = None ) : if isinstance ( bins , numbers . Integral ) : nx = ny = bins else : nx , ny = bins if not np . isscalar ( nx ) or not np . isscalar ( ny ) : raise TypeError ( 'bins should be an iterable of two integers' ) ( xmin , xmax ) , ( ymin , ymax ) = range if not np . isfinite ( xmin ) : raise ValueError ( "xmin should be finite" ) if not np . isfinite ( xmax ) : raise ValueError ( "xmax should be finite" ) if not np . isfinite ( ymin ) : raise ValueError ( "ymin should be finite" ) if not np . isfinite ( ymax ) : raise ValueError ( "ymax should be finite" ) if xmax <= xmin : raise ValueError ( "xmax should be greater than xmin" ) if ymax <= ymin : raise ValueError ( "xmax should be greater than xmin" ) if nx <= 0 : raise ValueError ( "nx should be strictly positive" ) if ny <= 0 : raise ValueError ( "ny should be strictly positive" ) if weights is None : return _histogram2d ( x , y , nx , xmin , xmax , ny , ymin , ymax ) else : return _histogram2d_weighted ( x , y , weights , nx , xmin , xmax , ny , ymin , ymax ) | Compute a 2D histogram assuming equally spaced bins . |
56,005 | def to_networkx ( self ) : return nx_util . to_networkx ( self . session . get ( self . __url ) . json ( ) ) | Return this network in NetworkX graph object . |
56,006 | def to_dataframe ( self , extra_edges_columns = [ ] ) : return df_util . to_dataframe ( self . session . get ( self . __url ) . json ( ) , edges_attr_cols = extra_edges_columns ) | Return this network in pandas DataFrame . |
56,007 | def add_node ( self , node_name , dataframe = False ) : if node_name is None : return None return self . add_nodes ( [ node_name ] , dataframe = dataframe ) | Add a single node to the network . |
56,008 | def add_nodes ( self , node_name_list , dataframe = False ) : res = self . session . post ( self . __url + 'nodes' , data = json . dumps ( node_name_list ) , headers = HEADERS ) check_response ( res ) nodes = res . json ( ) if dataframe : return pd . DataFrame ( nodes ) . set_index ( [ 'SUID' ] ) else : return { node [ 'name' ] : node [ 'SUID' ] for node in nodes } | Add new nodes to the network |
56,009 | def add_edge ( self , source , target , interaction = '-' , directed = True , dataframe = True ) : new_edge = { 'source' : source , 'target' : target , 'interaction' : interaction , 'directed' : directed } return self . add_edges ( [ new_edge ] , dataframe = dataframe ) | Add a single edge from source to target . |
56,010 | def get_views ( self ) : url = self . __url + 'views' return self . session . get ( url ) . json ( ) | Get views as a list of SUIDs |
56,011 | def diffuse_advanced ( self , heatColumnName = None , time = None , verbose = False ) : PARAMS = set_param ( [ "heatColumnName" , "time" ] , [ heatColumnName , time ] ) response = api ( url = self . __url + "/diffuse_advanced" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Diffusion will send the selected network view and its selected nodes to a web - based REST service to calculate network propagation . Results are returned and represented by columns in the node table . Columns are created for each execution of Diffusion and their names are returned in the response . |
56,012 | def to_networkx ( cyjs , directed = True ) : if directed : g = nx . MultiDiGraph ( ) else : g = nx . MultiGraph ( ) network_data = cyjs [ DATA ] if network_data is not None : for key in network_data . keys ( ) : g . graph [ key ] = network_data [ key ] nodes = cyjs [ ELEMENTS ] [ NODES ] edges = cyjs [ ELEMENTS ] [ EDGES ] for node in nodes : data = node [ DATA ] g . add_node ( data [ ID ] , attr_dict = data ) for edge in edges : data = edge [ DATA ] source = data [ SOURCE ] target = data [ TARGET ] g . add_edge ( source , target , attr_dict = data ) return g | Convert Cytoscape . js - style JSON object into NetworkX object . |
56,013 | def dialog ( self = None , wid = None , text = None , title = None , url = None , debug = False , verbose = False ) : PARAMS = set_param ( [ "id" , "text" , "title" , "url" , "debug" ] , [ wid , text , title , url , debug ] ) response = api ( url = self . __url + "/dialog?" , PARAMS = PARAMS , method = "GET" , verbose = verbose ) return response | Launch and HTML browser in a separate window . |
56,014 | def hide ( self , wid , verbose = False ) : PARAMS = { "id" : wid } response = api ( url = self . __url + "/hide?" , PARAMS = PARAMS , method = "GET" , verbose = verbose ) return response | Hide and HTML browser in the Results Panel . |
56,015 | def show ( self , wid = None , text = None , title = None , url = None , verbose = False ) : PARAMS = { } for p , v in zip ( [ "id" , "text" , "title" , "url" ] , [ wid , text , title , url ] ) : if v : PARAMS [ p ] = v response = api ( url = self . __url + "/show?" , PARAMS = PARAMS , method = "GET" , verbose = verbose ) return response | Launch an HTML browser in the Results Panel . |
56,016 | def check_response ( res ) : try : res . raise_for_status ( ) except Exception as exc : try : err_info = res . json ( ) err_msg = err_info [ 'message' ] except ValueError : err_msg = res . text [ : 40 ] except KeyError : err_msg = res . text [ : 40 ] + ( "(No 'message' in err_info dict: %s" % list ( err_info . keys ( ) ) ) exc . args += ( err_msg , ) raise exc | Check HTTP response and raise exception if response is not OK . |
56,017 | def from_dataframe ( df , source_col = 'source' , target_col = 'target' , interaction_col = 'interaction' , name = 'From DataFrame' , edge_attr_cols = [ ] ) : network = cyjs . get_empty_network ( name = name ) nodes = set ( ) if edge_attr_cols is None : edge_attr_cols = [ ] for index , row in df . iterrows ( ) : s = row [ source_col ] t = row [ target_col ] if s not in nodes : nodes . add ( s ) source = get_node ( s ) network [ 'elements' ] [ 'nodes' ] . append ( source ) if t not in nodes : nodes . add ( t ) target = get_node ( t ) network [ 'elements' ] [ 'nodes' ] . append ( target ) extra_values = { column : row [ column ] for column in edge_attr_cols if column in df . columns } network [ 'elements' ] [ 'edges' ] . append ( get_edge ( s , t , interaction = row [ interaction_col ] , ** extra_values ) ) return network | Utility to convert Pandas DataFrame object into Cytoscape . js JSON |
56,018 | def to_dataframe ( network , interaction = 'interaction' , default_interaction = '-' , edges_attr_cols = [ ] ) : edges = network [ 'elements' ] [ 'edges' ] if edges_attr_cols is None : edges_attr_cols = [ ] edges_attr_cols = sorted ( edges_attr_cols ) network_array = [ ] valid_extra_cols = set ( ) for edge in edges : edge_data = edge [ 'data' ] source = edge_data [ 'source' ] target = edge_data [ 'target' ] if interaction in edge_data : itr = edge_data [ interaction ] else : itr = default_interaction extra_values = [ ] for extra_column in edges_attr_cols : if extra_column in edge_data : extra_values . append ( edge_data [ extra_column ] ) valid_extra_cols . add ( extra_column ) row = tuple ( [ source , itr , target ] + extra_values ) network_array . append ( row ) return pd . DataFrame ( network_array , columns = [ 'source' , 'interaction' , 'target' ] + sorted ( valid_extra_cols ) ) | Utility to convert a Cytoscape dictionary into a Pandas Dataframe . |
56,019 | def render ( network , style = DEF_STYLE , layout_algorithm = DEF_LAYOUT , background = DEF_BACKGROUND_COLOR , height = DEF_HEIGHT , width = DEF_WIDTH , style_file = STYLE_FILE , def_nodes = DEF_NODES , def_edges = DEF_EDGES ) : from jinja2 import Template from IPython . core . display import display , HTML STYLES = set_styles ( style_file ) if isinstance ( style , str ) : style = STYLES [ style ] if network is None : nodes = def_nodes edges = def_edges else : nodes = network [ 'elements' ] [ 'nodes' ] edges = network [ 'elements' ] [ 'edges' ] path = os . path . abspath ( os . path . dirname ( __file__ ) ) + '/' + HTML_TEMPLATE_FILE template = Template ( open ( path ) . read ( ) ) cyjs_widget = template . render ( nodes = json . dumps ( nodes ) , edges = json . dumps ( edges ) , background = background , uuid = "cy" + str ( uuid . uuid4 ( ) ) , widget_width = str ( width ) , widget_height = str ( height ) , layout = layout_algorithm , style_json = json . dumps ( style ) ) display ( HTML ( cyjs_widget ) ) | Render network data with embedded Cytoscape . js widget . |
56,020 | def create_attribute ( self , column = None , listType = None , namespace = None , network = None , atype = None , verbose = False ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ "column" , "listType" , "namespace" , "network" , "type" ] , [ column , listType , namespace , network , atype ] ) response = api ( url = self . __url + "/create attribute" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Creates a new edge column . |
56,021 | def get ( self , edge = None , network = None , sourceNode = None , targetNode = None , atype = None , verbose = False ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ "edge" , "network" , "sourceNode" , "targetNode" , "type" ] , [ edge , network , sourceNode , targetNode , atype ] ) response = api ( url = self . __url + "/get" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Returns the SUID of an edge that matches the passed parameters . If multiple edges are found only one will be returned and a warning will be reported in the Cytoscape Task History dialog . |
56,022 | def add_edge ( self , isDirected = None , name = None , network = None , sourceName = None , targetName = None , verbose = False ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ "isDirected" , "name" , "network" , "sourceName" , "targetName" ] , [ isDirected , name , network , sourceName , targetName ] ) response = api ( url = self . __url + "/add edge" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Add a new edge between two existing nodes in a network . The names of the nodes must be specified and much match the value in the name column for each node . |
56,023 | def create ( self , edgeList = None , excludeEdges = None , networkName = None , nodeList = None , source = None , verbose = False ) : network = check_network ( self , source , verbose = verbose ) PARAMS = set_param ( [ "edgeList" , "excludeEdges" , "networkName" , "nodeList" , "source" ] , [ edgeList , excludeEdges , networkName , nodeList , network ] ) response = api ( url = self . __url + "/create" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Create a new network from a list of nodes and edges in an existing source network . The SUID of the network and view are returned . |
56,024 | def create_empty ( self , name = None , renderers = None , RootNetworkList = None , verbose = False ) : PARAMS = set_param ( [ "name" , "renderers" , "RootNetworkList" ] , [ name , renderers , RootNetworkList ] ) response = api ( url = self . __url + "/create empty" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Create a new empty network . The new network may be created as part of an existing network collection or a new network collection . |
56,025 | def list ( self , verbose = False ) : response = api ( url = self . __url + "/list" , method = "POST" , verbose = verbose ) return response | List all of the networks in the current session . |
56,026 | def list_attributes ( self , namespace = None , network = None , verbose = False ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ "namespace" , "network" ] , [ namespace , network ] ) response = api ( url = self . __url + "/list attributes" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Returns a list of column names assocated with a network . |
56,027 | def rename ( self , name = None , sourceNetwork = None , verbose = False ) : sourceNetwork = check_network ( self , sourceNetwork , verbose = verbose ) PARAMS = set_param ( [ "name" , "sourceNetwork" ] , [ name , sourceNetwork ] ) response = api ( url = self . __url + "/rename" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Rename an existing network . The SUID of the network is returned |
56,028 | def new ( self , verbose = False ) : response = api ( url = self . __url + "/new" , verbose = verbose ) return response | Destroys the current session and creates a new empty one . |
56,029 | def open ( self , session_file = None , session_url = None , verbose = False ) : PARAMS = set_param ( [ "file" , "url" ] , [ session_file , session_url ] ) response = api ( url = self . __url + "/open" , PARAMS = PARAMS , verbose = verbose ) return response | Opens a session from a local file or URL . |
56,030 | def save ( self , session_file , verbose = False ) : PARAMS = { "file" : session_file } response = api ( url = self . __url + "/save" , PARAMS = PARAMS , verbose = verbose ) return response | Saves the current session to an existing file which will be replaced . If this is a new session that has not been saved yet use save as instead . |
56,031 | def apply ( self , styles = None , verbose = False ) : PARAMS = set_param ( [ "styles" ] , [ styles ] ) response = api ( url = self . __url + "/apply" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Applies the specified style to the selected views and returns the SUIDs of the affected views . |
56,032 | def create_style ( self , title = None , defaults = None , mappings = None , verbose = VERBOSE ) : u = self . __url host = u . split ( "//" ) [ 1 ] . split ( ":" ) [ 0 ] port = u . split ( ":" ) [ 2 ] . split ( "/" ) [ 0 ] version = u . split ( ":" ) [ 2 ] . split ( "/" ) [ 1 ] if defaults : defaults_ = [ ] for d in defaults : if d : defaults_ . append ( d ) defaults = defaults_ if mappings : mappings_ = [ ] for m in mappings : if m : mappings_ . append ( m ) mappings = mappings_ try : update_style ( title = title , defaults = defaults , mappings = mappings , host = host , port = port ) print ( "Existing style was updated." ) sys . stdout . flush ( ) except : print ( "Creating new style." ) sys . stdout . flush ( ) URL = "http://" + str ( host ) + ":" + str ( port ) + "/v1/styles" PARAMS = { "title" : title , "defaults" : defaults , "mappings" : mappings } r = requests . post ( url = URL , json = PARAMS ) checkresponse ( r ) | Creates a new visual style |
56,033 | def update_style ( self , title = None , defaults = None , mappings = None , verbose = False ) : u = self . __url host = u . split ( "//" ) [ 1 ] . split ( ":" ) [ 0 ] port = u . split ( ":" ) [ 2 ] . split ( "/" ) [ 0 ] version = u . split ( ":" ) [ 2 ] . split ( "/" ) [ 1 ] if defaults : defaults_ = [ ] for d in defaults : if d : defaults_ . append ( d ) defaults = defaults_ if mappings : mappings_ = [ ] for m in mappings : if m : mappings_ . append ( m ) mappings = mappings_ URL = "http://" + str ( host ) + ":" + str ( port ) + "/v1/styles/" + str ( title ) if verbose : print ( URL ) sys . stdout . flush ( ) response = requests . get ( URL ) . json ( ) olddefaults = response [ "defaults" ] oldmappings = response [ "mappings" ] if mappings : mappings_visual_properties = [ m [ "visualProperty" ] for m in mappings ] newmappings = [ m for m in oldmappings if m [ "visualProperty" ] not in mappings_visual_properties ] for m in mappings : newmappings . append ( m ) else : newmappings = oldmappings if defaults : defaults_visual_properties = [ m [ "visualProperty" ] for m in defaults ] newdefaults = [ m for m in olddefaults if m [ "visualProperty" ] not in defaults_visual_properties ] for m in defaults : newdefaults . append ( m ) else : newdefaults = olddefaults r = requests . delete ( URL ) checkresponse ( r ) URL = "http://" + str ( host ) + ":" + str ( port ) + "/v1/styles" PARAMS = { "title" : title , "defaults" : newdefaults , "mappings" : newmappings } r = requests . post ( url = URL , json = PARAMS ) checkresponse ( r ) | Updates a visual style |
56,034 | def simple_defaults ( self , defaults_dic ) : defaults = [ ] for d in defaults_dic . keys ( ) : dic = { } dic [ "visualProperty" ] = d dic [ "value" ] = defaults_dic [ d ] defaults . append ( dic ) return defaults | Simplifies defaults . |
56,035 | def attribute_circle ( self , EdgeAttribute = None , network = None , NodeAttribute = None , nodeList = None , singlePartition = None , spacing = None , verbose = False ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ "EdgeAttribute" , "network" , "NodeAttribute" , "nodeList" , "singlePartition" , "spacing" ] , [ EdgeAttribute , network , NodeAttribute , nodeList , singlePartition , spacing ] ) response = api ( url = self . __url + "/attribute-circle" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Attribute Circle Layout on a network . |
56,036 | def attributes_layout ( self , EdgeAttribute = None , maxwidth = None , minrad = None , network = None , NodeAttribute = None , nodeList = None , radmult = None , spacingx = None , spacingy = None , verbose = False ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ "EdgeAttribute" , "network" , "NodeAttribute" , "nodeList" , "singlePartition" , "spacing" ] , [ EdgeAttribute , maxwidth , minrad , network , NodeAttribute , nodeList , radmult , spacingx , spacingy ] ) response = api ( url = self . __url + "/attributes-layout" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Group Attributes Layout on a network |
56,037 | def circular ( self , EdgeAttribute = None , leftEdge = None , network = None , NodeAttribute = None , nodeHorizontalSpacing = None , nodeList = None , nodeVerticalSpacing = None , rightMargin = None , singlePartition = None , topEdge = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'EdgeAttribute' , 'leftEdge' , 'network' , 'NodeAttribute' , 'nodeHorizontalSpacing' , 'nodeList' , 'nodeVerticalSpacing' , 'rightMargin' , 'singlePartition' , 'topEdge' ] , [ EdgeAttribute , leftEdge , network , NodeAttribute , nodeHorizontalSpacing , nodeList , nodeVerticalSpacing , rightMargin , singlePartition , topEdge ] ) response = api ( url = self . __url + "/circular" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Circular Layout on a network |
56,038 | def copycat ( self , gridUnmapped = None , selectUnmapped = None , sourceColumn = None , sourceNetwork = None , targetColumn = None , targetNetwork = None , verbose = None ) : PARAMS = set_param ( [ 'gridUnmapped' , 'selectUnmapped' , 'sourceColumn' , 'sourceNetwork' , 'targetColumn' , 'targetNetwork' ] , [ gridUnmapped , selectUnmapped , sourceColumn , sourceNetwork , targetColumn , targetNetwork ] ) response = api ( url = self . __url + "/copycat" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Sets the coordinates for each node in the target network to the coordinates of a matching node in the source network . Optional parameters such as gridUnmapped and selectUnmapped determine the behavior of target network nodes that could not be matched . |
56,039 | def degree_circle ( self , EdgeAttribute = None , network = None , NodeAttribute = None , nodeList = None , singlePartition = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'EdgeAttribute' , 'network' , 'NodeAttribute' , 'nodeList' , 'singlePartition' ] , [ EdgeAttribute , network , NodeAttribute , nodeList , singlePartition ] ) response = api ( url = self . __url + "/degree-circle" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Degree Sorted Circle Layout on a network . |
56,040 | def force_directed ( self , defaultEdgeWeight = None , defaultNodeMass = None , defaultSpringCoefficient = None , defaultSpringLength = None , EdgeAttribute = None , isDeterministic = None , maxWeightCutoff = None , minWeightCutoff = None , network = None , NodeAttribute = None , nodeList = None , numIterations = None , singlePartition = None , Type = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'defaultEdgeWeight' , 'defaultNodeMass' , 'defaultSpringCoefficient' , 'defaultSpringLength' , 'EdgeAttribute' , 'isDeterministic' , 'maxWeightCutoff' , 'minWeightCutoff' , 'network' , 'NodeAttribute' , 'nodeList' , 'numIterations' , 'singlePartition' , 'Type' ] , [ defaultEdgeWeight , defaultNodeMass , defaultSpringCoefficient , defaultSpringLength , EdgeAttribute , isDeterministic , maxWeightCutoff , minWeightCutoff , network , NodeAttribute , nodeList , numIterations , singlePartition , Type ] ) response = api ( url = self . __url + "/force-directed" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Prefuse Force Directed Layout on a network |
56,041 | def genemania_force_directed ( self , curveSteepness = None , defaultEdgeWeight = None , defaultSpringCoefficient = None , defaultSpringLength = None , EdgeAttribute = None , ignoreHiddenElements = None , isDeterministic = None , maxNodeMass = None , maxWeightCutoff = None , midpointEdges = None , minNodeMass = None , minWeightCutoff = None , network = None , NodeAttribute = None , nodeList = None , numIterations = None , singlePartition = None , Type = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'curveSteepness' , 'defaultEdgeWeight' , 'defaultSpringCoefficient' , 'defaultSpringLength' , 'EdgeAttribute' , 'ignoreHiddenElements' , 'isDeterministic' , 'maxNodeMass' , 'maxWeightCutoff' , 'midpointEdges' , 'minNodeMass' , 'minWeightCutoff' , 'network' , 'NodeAttribute' , 'nodeList' , 'numIterations' , 'singlePartition' , 'Type' ] , [ curveSteepness , defaultEdgeWeight , defaultSpringCoefficient , defaultSpringLength , EdgeAttribute , ignoreHiddenElements , isDeterministic , maxNodeMass , maxWeightCutoff , midpointEdges , minNodeMass , minWeightCutoff , network , NodeAttribute , nodeList , numIterations , singlePartition , Type ] ) response = api ( url = self . __url + "/genemania-force-directed" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the GeneMANIA Force Directed Layout on a network . |
56,042 | def get_preferred ( self , network = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'network' ] , [ network ] ) response = api ( url = self . __url + "/get preferred" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Returns the name of the current preferred layout or empty string if not set . Default is grid . |
56,043 | def grid ( self , EdgeAttribute = None , network = None , NodeAttribute = None , nodeHorizontalSpacing = None , nodeList = None , nodeVerticalSpacing = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'EdgeAttribute' , 'network' , 'NodeAttribute' , 'nodeHorizontalSpacing' , 'nodeList' , 'nodeVerticalSpacing' ] , [ EdgeAttribute , network , NodeAttribute , nodeHorizontalSpacing , nodeList , nodeVerticalSpacing ] ) response = api ( url = self . __url + "/grid" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Grid Layout on a network . |
56,044 | def hierarchical ( self , bandGap = None , componentSpacing = None , EdgeAttribute = None , leftEdge = None , network = None , NodeAttribute = None , nodeHorizontalSpacing = None , nodeList = None , nodeVerticalSpacing = None , rightMargin = None , topEdge = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'bandGap' , 'componentSpacing' , 'EdgeAttribute' , 'leftEdge' , 'network' , 'NodeAttribute' , 'nodeHorizontalSpacing' , 'nodeList' , 'nodeVerticalSpacing' , 'rightMargin' , 'topEdge' ] , [ bandGap , componentSpacing , EdgeAttribute , leftEdge , network , NodeAttribute , nodeHorizontalSpacing , nodeList , nodeVerticalSpacing , rightMargin , topEdge ] ) response = api ( url = self . __url + "/hierarchical" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Hierarchical Layout on a network . |
56,045 | def isom ( self , coolingFactor = None , EdgeAttribute = None , initialAdaptation = None , maxEpoch = None , minAdaptation = None , minRadius = None , network = None , NodeAttribute = None , nodeList = None , radius = None , radiusConstantTime = None , singlePartition = None , sizeFactor = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'coolingFactor' , 'EdgeAttribute' , 'initialAdaptation' , 'maxEpoch' , 'minAdaptation' , 'minRadius' , 'network' , 'NodeAttribute' , 'nodeList' , 'radius' , 'radiusConstantTime' , 'singlePartition' , 'sizeFactor' ] , [ coolingFactor , EdgeAttribute , initialAdaptation , maxEpoch , minAdaptation , minRadius , network , NodeAttribute , nodeList , radius , radiusConstantTime , singlePartition , sizeFactor ] ) response = api ( url = self . __url + "/isom" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Inverted Self - Organizing Map Layout on a network . |
56,046 | def kamada_kawai ( self , defaultEdgeWeight = None , EdgeAttribute = None , m_anticollisionSpringStrength = None , m_averageIterationsPerNode = None , m_disconnectedNodeDistanceSpringRestLength = None , m_disconnectedNodeDistanceSpringStrength = None , m_layoutPass = None , m_nodeDistanceRestLengthConstant = None , m_nodeDistanceStrengthConstant = None , maxWeightCutoff = None , minWeightCutoff = None , network = None , NodeAttribute = None , nodeList = None , randomize = None , singlePartition = None , Type = None , unweighted = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'defaultEdgeWeight' , 'EdgeAttribute' , 'm_anticollisionSpringStrength' , 'm_averageIterationsPerNode' , 'm_disconnectedNodeDistanceSpringRestLength' , 'm_disconnectedNodeDistanceSpringStrength' , 'm_layoutPass' , 'm_nodeDistanceRestLengthConstant' , 'm_nodeDistanceStrengthConstant' , 'maxWeightCutoff' , 'minWeightCutoff' , 'network' , 'NodeAttribute' , 'nodeList' , 'randomize' , 'singlePartition' , 'Type' , 'unweighted' ] , [ defaultEdgeWeight , EdgeAttribute , m_anticollisionSpringStrength , m_averageIterationsPerNode , m_disconnectedNodeDistanceSpringRestLength , m_disconnectedNodeDistanceSpringStrength , m_layoutPass , m_nodeDistanceRestLengthConstant , m_nodeDistanceStrengthConstant , maxWeightCutoff , minWeightCutoff , network , NodeAttribute , nodeList , randomize , singlePartition , Type , unweighted ] ) response = api ( url = self . __url + "/kamada-kawai" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Edge - weighted Spring Embedded Layout on a network . |
56,047 | def set_preferred ( self , preferredLayout = None , verbose = None ) : PARAMS = set_param ( [ 'preferredLayout' ] , [ preferredLayout ] ) response = api ( url = self . __url + "/set preferred" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Sets the preferred layout . Takes a specific name as defined in the API Default is grid . |
56,048 | def stacked_node_layout ( self , EdgeAttribute = None , network = None , NodeAttribute = None , nodeList = None , x_position = None , y_start_position = None , verbose = None ) : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ 'EdgeAttribute' , 'network' , 'NodeAttribute' , 'nodeList' , 'x_position' , 'y_start_position' ] , [ EdgeAttribute , network , NodeAttribute , nodeList , x_position , y_start_position ] ) response = api ( url = self . __url + "/stacked-node-layout" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Execute the Stacked Node Layout on a network . |
56,049 | def create_column ( self , columnName = None , listType = None , table = None , ntype = None , verbose = None ) : PARAMS = set_param ( [ 'columnName' , 'listType' , 'table' , 'type' ] , [ columnName , listType , table , ntype ] ) response = api ( url = self . __url + "/create column" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Appends an additional column of attribute values to the current table . |
56,050 | def create_table ( self , keyColumn = None , keyColumnType = None , title = None , verbose = None ) : PARAMS = set_param ( [ 'keyColumn' , 'keyColumnType' , 'title' ] , [ keyColumn , keyColumnType , title ] ) response = api ( url = self . __url + "/create table" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Adds a new table to the network . |
56,051 | def delete_column ( self , column = None , table = None , verbose = None ) : PARAMS = set_param ( [ 'column' , 'table' ] , [ column , table ] ) response = api ( url = self . __url + "/delete column" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Remove a column from a table specified by its name . Returns the name of the column removed . |
56,052 | def delete_row ( self , keyValue = None , table = None , verbose = None ) : PARAMS = set_param ( [ 'keyValue' , 'table' ] , [ keyValue , table ] ) response = api ( url = self . __url + "/delete row" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Deletes a row from a table . Requires the table name or SUID and the row key . |
56,053 | def get_value ( self , column = None , keyValue = None , table = None , verbose = None ) : PARAMS = set_param ( [ 'column' , 'keyValue' , 'table' ] , [ column , keyValue , table ] ) response = api ( url = self . __url + "/get value" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Returns the value from a cell as specified by row and column ids . |
56,054 | def import_url ( self , caseSensitiveNetworkCollectionKeys = None , caseSensitiveNetworkKeys = None , dataTypeList = None , DataTypeTargetForNetworkCollection = None , DataTypeTargetForNetworkList = None , delimiters = None , delimitersForDataList = None , firstRowAsColumnNames = None , KeyColumnForMapping = None , KeyColumnForMappingNetworkList = None , keyColumnIndex = None , newTableName = None , startLoadRow = None , TargetNetworkCollection = None , TargetNetworkList = None , url = None , WhereImportTable = None , verbose = None ) : PARAMS = set_param ( [ 'caseSensitiveNetworkCollectionKeys' , 'caseSensitiveNetworkKeys' , 'dataTypeList' , 'DataTypeTargetForNetworkCollection' , 'DataTypeTargetForNetworkList' , 'delimiters' , 'delimitersForDataList' , 'firstRowAsColumnNames' , 'KeyColumnForMapping' , 'KeyColumnForMappingNetworkList' , 'keyColumnIndex' , 'newTableName' , 'startLoadRow' , 'TargetNetworkCollection' , 'TargetNetworkList' , 'url' , 'WhereImportTable' ] , [ caseSensitiveNetworkCollectionKeys , caseSensitiveNetworkKeys , dataTypeList , DataTypeTargetForNetworkCollection , DataTypeTargetForNetworkList , delimiters , delimitersForDataList , firstRowAsColumnNames , KeyColumnForMapping , KeyColumnForMappingNetworkList , keyColumnIndex , newTableName , startLoadRow , TargetNetworkCollection , TargetNetworkList , url , WhereImportTable ] ) response = api ( url = self . __url + "/import url" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Similar to Import Table this uses a long list of input parameters to specify the attributes of the table the mapping keys and the destination table for the input . |
56,055 | def list_tables ( self , includePrivate = None , namespace = None , atype = None , verbose = None ) : PARAMS = set_param ( [ 'includePrivate' , 'namespace' , 'type' ] , [ includePrivate , namespace , atype ] ) response = api ( url = self . __url + "/list" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Returns a list of the table SUIDs associated with the passed network parameter . |
56,056 | def list_columns ( self , table = None , verbose = None ) : PARAMS = set_param ( [ 'table' ] , [ table ] ) response = api ( url = self . __url + "/list columns" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Returns the list of columns in the table . |
56,057 | def list_rows ( self , rowList = None , table = None , verbose = None ) : PARAMS = set_param ( [ 'rowList' , 'table' ] , [ rowList , table ] ) response = api ( url = self . __url + "/list rows" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Returns the list of primary keys for each of the rows in the specified table . |
56,058 | def merge ( self , DataTypeTargetForNetworkCollection = None , dataTypeTargetForNetworkList = None , mergeType = None , SourceMergeColumns = None , SourceMergeKey = None , SourceTable = None , TargetKeyNetworkCollection = None , TargetMergeKey = None , TargetNetworkCollection = None , TargetNetworkList = None , UnassignedTable = None , WhereMergeTable = None , verbose = None ) : PARAMS = set_param ( [ 'DataTypeTargetForNetworkCollection' , 'dataTypeTargetForNetworkList' , 'mergeType' , 'SourceMergeColumns' , 'SourceMergeKey' , 'SourceTable' , 'TargetKeyNetworkCollection' , 'TargetMergeKey' , 'TargetNetworkCollection' , 'TargetNetworkList' , 'UnassignedTable' , 'WhereMergeTable' ] , [ DataTypeTargetForNetworkCollection , dataTypeTargetForNetworkList , mergeType , SourceMergeColumns , SourceMergeKey , SourceTable , TargetKeyNetworkCollection , TargetMergeKey , TargetNetworkCollection , TargetNetworkList , UnassignedTable , WhereMergeTable ] ) response = api ( url = self . __url + "/merge" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Merge tables together joining around a designated key column . Depending on the arguments might merge into multiple local tables . |
56,059 | def rename_column ( self , columnName = None , newColumnName = None , table = None , verbose = None ) : PARAMS = set_param ( [ 'columnName' , 'newColumnName' , 'table' ] , [ columnName , newColumnName , table ] ) response = api ( url = self . __url + "/rename column" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Changes the name of a specified column in the table . |
56,060 | def set_title ( self , table = None , title = None , verbose = None ) : PARAMS = set_param ( [ 'table' , 'title' ] , [ table , title ] ) response = api ( url = self . __url + "/set title" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Changes the visible identifier of a single table . |
56,061 | def set_values ( self , columnName = None , rowList = None , table = None , value = None , verbose = None ) : PARAMS = set_param ( [ 'columnName' , 'rowList' , 'table' , 'value' ] , [ columnName , rowList , table , value ] ) response = api ( url = self . __url + "/set values" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Set all the values in the specified list of rows with a single value . |
56,062 | def getTable ( self , columns = None , table = None , network = "current" , namespace = 'default' , verbose = VERBOSE ) : u = self . __url host = u . split ( "//" ) [ 1 ] . split ( ":" ) [ 0 ] port = u . split ( ":" ) [ 2 ] . split ( "/" ) [ 0 ] version = u . split ( ":" ) [ 2 ] . split ( "/" ) [ 1 ] if type ( network ) != int : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ "columnList" , "namespace" , "network" ] , [ "SUID" , namespace , network ] ) network = api ( namespace = "network" , command = "get attribute" , PARAMS = PARAMS , host = host , port = str ( port ) , version = version ) network = network [ 0 ] [ "SUID" ] df = pd . DataFrame ( ) def target ( column ) : URL = "http://" + str ( host ) + ":" + str ( port ) + "/v1/networks/" + str ( network ) + "/tables/" + namespace + table + "/columns/" + column if verbose : print ( "'" + URL + "'" ) sys . stdout . flush ( ) response = urllib2 . urlopen ( URL ) response = response . read ( ) colA = json . loads ( response ) col = pd . DataFrame ( ) colHeader = colA [ "name" ] colValues = colA [ "values" ] col [ colHeader ] = colValues return col ncols = [ "name" ] for c in columns : ncols . append ( c . replace ( " " , "%20" ) ) for c in ncols : try : col = target ( c ) df = pd . concat ( [ df , col ] , axis = 1 ) except : print ( "Could not find " + c ) sys . stdout . flush ( ) df . index = df [ "name" ] . tolist ( ) df = df . drop ( [ "name" ] , axis = 1 ) return df | Gets tables from cytoscape . |
56,063 | def loadTableData ( self , df , df_key = 'index' , table = "node" , table_key_column = "name" , network = "current" , namespace = "default" , verbose = False ) : u = self . __url host = u . split ( "//" ) [ 1 ] . split ( ":" ) [ 0 ] port = u . split ( ":" ) [ 2 ] . split ( "/" ) [ 0 ] version = u . split ( ":" ) [ 2 ] . split ( "/" ) [ 1 ] if type ( network ) != int : network = check_network ( self , network , verbose = verbose ) PARAMS = set_param ( [ "columnList" , "namespace" , "network" ] , [ "SUID" , namespace , network ] ) networkID = api ( namespace = "network" , command = "get attribute" , PARAMS = PARAMS , host = host , port = str ( port ) , version = version ) PARAMS = set_param ( [ "columnList" , "namespace" , "network" ] , [ "name" , namespace , network ] ) networkname = api ( namespace = "network" , command = "get attribute" , PARAMS = PARAMS , host = host , port = str ( port ) , version = version ) network = networkID [ 0 ] [ "SUID" ] networkname = networkname [ 0 ] [ "name" ] tmp = df . copy ( ) if df_key != "index" : tmp . index = tmp [ df_key ] . tolist ( ) tmp = tmp . drop ( [ df_key ] , axis = 1 ) tablen = networkname + " default node" data = [ ] for c in tmp . columns . tolist ( ) : tmpcol = tmp [ [ c ] ] . dropna ( ) for r in tmpcol . index . tolist ( ) : cell = { } cell [ str ( table_key_column ) ] = str ( r ) val = tmpcol . loc [ r , c ] if type ( val ) != str : val = float ( val ) cell [ str ( c ) ] = val data . append ( cell ) upload = { "key" : table_key_column , "dataKey" : table_key_column , "data" : data } URL = "http://" + str ( host ) + ":" + str ( port ) + "/v1/networks/" + str ( network ) + "/tables/" + namespace + table if verbose : print ( "'" + URL + "'" , upload ) sys . stdout . flush ( ) r = requests . put ( url = URL , json = upload ) if verbose : print ( r ) checkresponse ( r ) res = r . content return res | Loads tables into cytoscape . |
56,064 | def getTableCount ( verbose = None ) : response = api ( url = self . url + 'tables/count' , method = "GET" , verbose = verbose , parse_params = False ) return response | Returns the number of global tables . |
56,065 | def set_value ( self , visual_property , value ) : if visual_property is None or value is None : raise ValueError ( 'Both VP and value are required.' ) new_value = [ { 'visualProperty' : visual_property , "value" : value } ] requests . put ( self . url , data = json . dumps ( new_value ) , headers = HEADERS ) | Set a single Visual Property Value |
56,066 | def set_values ( self , values ) : if values is None : raise ValueError ( 'Values are required.' ) new_values = [ ] for vp in values . keys ( ) : new_val = { 'visualProperty' : vp , 'value' : values [ vp ] } new_values . append ( new_val ) requests . put ( self . url , data = json . dumps ( new_values ) , headers = HEADERS ) | Set multiple Visual properties at once . |
56,067 | def get_value ( self , visual_property ) : res = requests . get ( self . url + '/' + visual_property ) return res . json ( ) [ 'value' ] | Get a value for the Visual Property |
56,068 | def get_values ( self ) : results = requests . get ( self . url ) . json ( ) values = { } for entry in results : values [ entry [ 'visualProperty' ] ] = entry [ 'value' ] return values | Get all visual property values for the object |
56,069 | def update_network_view ( self , visual_property = None , value = None ) : new_value = [ { "visualProperty" : visual_property , "value" : value } ] res = requests . put ( self . __url + '/network' , data = json . dumps ( new_value ) , headers = HEADERS ) check_response ( res ) | Updates single value for Network - related VP . |
56,070 | def export ( self , Height = None , options = None , outputFile = None , Resolution = None , Units = None , Width = None , Zoom = None , view = "current" , verbose = False ) : PARAMS = set_param ( [ "Height" , "options" , "outputFile" , "Resolution" , "Units" , "Width" , "Zoom" , "view" ] , [ Height , options , outputFile , Resolution , Units , Width , Zoom , view ] ) response = api ( url = self . __url + "/export" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Exports the current view to a graphics file and returns the path to the saved file . PNG and JPEG formats have options for scaling while other formats only have the option exportTextAsFont . For the PDF format exporting text as font does not work for two - byte characters such as Chinese or Japanese . To avoid corrupted texts in the exported PDF please set false to exportTextAsFont when exporting networks including those non - English characters . |
56,071 | def fit_content ( self , verbose = False ) : PARAMS = { } response = api ( url = self . __url + "/fit content" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Zooms out the current view in order to display all of its elements . |
56,072 | def get_current ( self , layout = None , network = None , verbose = False ) : PARAMS = { } response = api ( url = self . __url + "/get_current" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Returns the current view or null if there is none . |
56,073 | def update_defaults ( self , prop_value_dict ) : body = [ ] for key in prop_value_dict : entry = { 'visualProperty' : key , 'value' : prop_value_dict [ key ] } body . append ( entry ) url = self . __url + 'defaults' requests . put ( url , data = json . dumps ( body ) , headers = HEADERS ) | Updates the value of one or more visual properties . |
56,074 | def status ( self , verbose = False ) : try : response = api ( url = self . __url , method = "GET" , verbose = verbose ) except Exception as e : print ( 'Could not get status from CyREST:\n\n' + str ( e ) ) else : print ( 'CyREST online!' ) | Checks the status of your CyREST server . |
56,075 | def version ( self , verbose = False ) : response = api ( url = self . __url + "version" , method = "H" , verbose = verbose ) response = json . loads ( response ) for k in response . keys ( ) : print ( k , response [ k ] ) | Checks Cytoscape version |
56,076 | def map_column ( self , only_use_one = None , source_column = None , species = None , target_selection = None , verbose = False ) : PARAMS = set_param ( [ "only_use_one" , "source_column" , "species" , "target_selection" ] , [ only_use_one , source_column , species , target_selection ] ) response = api ( url = self . __url + "/map column" , PARAMS = PARAMS , method = "POST" , verbose = verbose ) return response | Uses the BridgeDB service to look up analogous identifiers from a wide selection of other databases |
56,077 | def echo ( self , variableName , verbose = False ) : PARAMS = { "variableName" : variableName } response = api ( url = self . __url + "/echo" , PARAMS = PARAMS , verbose = verbose ) return response | The echo command will display the value of the variable specified by the variableName argument or all variables if variableName is not provided . |
56,078 | def open_dialog ( self , verbose = False ) : response = api ( url = self . __url + "/open dialog" , verbose = verbose ) return response | The command line dialog provides a field to enter commands and view results . It also provides the help command to display namespaces commands and arguments . |
56,079 | def pause ( self , message = None , verbose = False ) : PARAMS = set_param ( [ "message" ] , [ message ] ) response = api ( url = self . __url + "/pause" , PARAMS = PARAMS , verbose = verbose ) return response | The pause command displays a dialog with the text provided in the message argument and waits for the user to click OK |
56,080 | def quit ( self , verbose = False ) : response = api ( url = self . __url + "/quit" , verbose = verbose ) return response | This command causes Cytoscape to exit . It is typically used at the end of a script file . |
56,081 | def run ( self , script_file , args = None , verbose = False ) : PARAMS = set_param ( [ "file" , "args" ] , [ script_file , args ] ) response = api ( url = self . __url + "/run" , PARAMS = PARAMS , verbose = verbose ) return response | The run command will execute a command script from the file pointed to by the file argument which should contain Cytoscape commands one per line . Arguments to the script are provided by the args argument . |
56,082 | def sleep ( self , duration , verbose = False ) : PARAMS = { "duration" : str ( duration ) } response = api ( url = self . __url + "/sleep" , PARAMS = PARAMS , verbose = verbose ) return response | The sleep command will pause processing for a period of time as specified by duration seconds . It is typically used as part of a command script . |
56,083 | def to_curl ( request , compressed = False , verify = True ) : parts = [ ( 'curl' , None ) , ( '-X' , request . method ) , ] for k , v in sorted ( request . headers . items ( ) ) : parts += [ ( '-H' , '{0}: {1}' . format ( k , v ) ) ] if request . body : body = request . body if isinstance ( body , bytes ) : body = body . decode ( 'utf-8' ) parts += [ ( '-d' , body ) ] if compressed : parts += [ ( '--compressed' , None ) ] if not verify : parts += [ ( '--insecure' , None ) ] parts += [ ( None , request . url ) ] flat_parts = [ ] for k , v in parts : if k : flat_parts . append ( k ) if v : flat_parts . append ( "'{0}'" . format ( v ) ) return ' ' . join ( flat_parts ) | Returns string with curl command by provided request object |
56,084 | def shared_options ( rq ) : "Default class options to pass to the CLI commands." return { 'url' : rq . redis_url , 'config' : None , 'worker_class' : rq . worker_class , 'job_class' : rq . job_class , 'queue_class' : rq . queue_class , 'connection_class' : rq . connection_class , } | Default class options to pass to the CLI commands . |
56,085 | def empty ( rq , ctx , all , queues ) : "Empty given queues." return ctx . invoke ( rq_cli . empty , all = all , queues = queues or rq . queues , ** shared_options ( rq ) ) | Empty given queues . |
56,086 | def requeue ( rq , ctx , all , job_ids ) : "Requeue failed jobs." return ctx . invoke ( rq_cli . requeue , all = all , job_ids = job_ids , ** shared_options ( rq ) ) | Requeue failed jobs . |
56,087 | def info ( rq , ctx , path , interval , raw , only_queues , only_workers , by_queue , queues ) : "RQ command-line monitor." return ctx . invoke ( rq_cli . info , path = path , interval = interval , raw = raw , only_queues = only_queues , only_workers = only_workers , by_queue = by_queue , queues = queues or rq . queues , ** shared_options ( rq ) ) | RQ command - line monitor . |
56,088 | def worker ( rq , ctx , burst , logging_level , name , path , results_ttl , worker_ttl , verbose , quiet , sentry_dsn , exception_handler , pid , queues ) : "Starts an RQ worker." ctx . invoke ( rq_cli . worker , burst = burst , logging_level = logging_level , name = name , path = path , results_ttl = results_ttl , worker_ttl = worker_ttl , verbose = verbose , quiet = quiet , sentry_dsn = sentry_dsn , exception_handler = exception_handler or rq . _exception_handlers , pid = pid , queues = queues or rq . queues , ** shared_options ( rq ) ) | Starts an RQ worker . |
56,089 | def suspend ( rq , ctx , duration ) : "Suspends all workers." ctx . invoke ( rq_cli . suspend , duration = duration , ** shared_options ( rq ) ) | Suspends all workers . |
56,090 | def scheduler ( rq , ctx , verbose , burst , queue , interval , pid ) : "Periodically checks for scheduled jobs." scheduler = rq . get_scheduler ( interval = interval , queue = queue ) if pid : with open ( os . path . expanduser ( pid ) , 'w' ) as fp : fp . write ( str ( os . getpid ( ) ) ) if verbose : level = 'DEBUG' else : level = 'INFO' setup_loghandlers ( level ) scheduler . run ( burst = burst ) | Periodically checks for scheduled jobs . |
56,091 | def init_cli ( self , app ) : if click is None : raise RuntimeError ( 'Cannot import click. Is it installed?' ) from . cli import add_commands add_commands ( app . cli , self ) | Initialize the Flask CLI support in case it was enabled for the app . |
56,092 | def set_trace ( host = None , port = None , patch_stdstreams = False ) : if host is None : host = os . environ . get ( 'REMOTE_PDB_HOST' , '127.0.0.1' ) if port is None : port = int ( os . environ . get ( 'REMOTE_PDB_PORT' , '0' ) ) rdb = RemotePdb ( host = host , port = port , patch_stdstreams = patch_stdstreams ) rdb . set_trace ( frame = sys . _getframe ( ) . f_back ) | Opens a remote PDB on first available port . |
56,093 | def quasi_newton_uniform_lloyd ( points , cells , * args , omega = 1.0 , ** kwargs ) : def get_new_points ( mesh ) : x = ( mesh . node_coords - omega / 2 * jac_uniform ( mesh ) / mesh . control_volumes [ : , None ] ) idx = mesh . is_boundary_node & ~ ghosted_mesh . is_ghost_point x [ idx ] = mesh . node_coords [ idx ] x [ ghosted_mesh . is_ghost_point ] = ghosted_mesh . reflect_ghost ( x [ ghosted_mesh . mirrors ] ) return x ghosted_mesh = GhostedMesh ( points , cells ) runner ( get_new_points , ghosted_mesh , * args , ** kwargs , update_topology = lambda mesh : ghosted_mesh . update_topology ( ) , ) mesh = ghosted_mesh . get_unghosted_mesh ( ) return mesh . node_coords , mesh . cells [ "nodes" ] | Relaxed Lloyd s algorithm . omega = 1 leads to Lloyd s algorithm overrelaxation omega = 2 gives good results . Check out |
56,094 | def _energy_uniform_per_node ( X , cells ) : dim = 2 mesh = MeshTri ( X , cells ) star_integrals = numpy . zeros ( mesh . node_coords . shape [ 0 ] ) for cell , cell_volume in zip ( mesh . cells [ "nodes" ] , mesh . cell_volumes ) : for idx in cell : xi = mesh . node_coords [ idx ] tri = mesh . node_coords [ cell ] val = quadpy . triangle . integrate ( lambda x : numpy . einsum ( "ij,ij->i" , x . T - xi , x . T - xi ) , tri , quadpy . triangle . Dunavant ( 2 ) , ) star_integrals [ idx ] += val return star_integrals / ( dim + 1 ) | The CPT mesh energy is defined as |
56,095 | def jac_uniform ( X , cells ) : dim = 2 mesh = MeshTri ( X , cells ) jac = numpy . zeros ( X . shape ) for k in range ( mesh . cells [ "nodes" ] . shape [ 1 ] ) : i = mesh . cells [ "nodes" ] [ : , k ] fastfunc . add . at ( jac , i , ( ( mesh . node_coords [ i ] - mesh . cell_barycenters ) . T * mesh . cell_volumes ) . T , ) return 2 / ( dim + 1 ) * jac | The approximated Jacobian is |
56,096 | def solve_hessian_approx_uniform ( X , cells , rhs ) : dim = 2 mesh = MeshTri ( X , cells ) row_idx = [ ] col_idx = [ ] val = [ ] cells = mesh . cells [ "nodes" ] . T n = X . shape [ 0 ] a = mesh . cell_volumes * ( 2 / ( dim + 1 ) ) for i in [ 0 , 1 , 2 ] : row_idx += [ cells [ i ] ] col_idx += [ cells [ i ] ] val += [ a ] a = mesh . cell_volumes * ( 2 / ( dim + 1 ) ** 2 ) for i in [ [ 0 , 1 , 2 ] , [ 1 , 2 , 0 ] , [ 2 , 0 , 1 ] ] : edges = cells [ i ] row_idx += [ edges [ 0 ] , edges [ 0 ] ] col_idx += [ edges [ 1 ] , edges [ 2 ] ] val += [ - a , - a ] row_idx = numpy . concatenate ( row_idx ) col_idx = numpy . concatenate ( col_idx ) val = numpy . concatenate ( val ) matrix = scipy . sparse . coo_matrix ( ( val , ( row_idx , col_idx ) ) , shape = ( n , n ) ) matrix = matrix . tocsr ( ) for i in numpy . where ( mesh . is_boundary_node ) [ 0 ] : matrix . data [ matrix . indptr [ i ] : matrix . indptr [ i + 1 ] ] = 0.0 d = matrix . diagonal ( ) d [ mesh . is_boundary_node ] = 1.0 matrix . setdiag ( d ) rhs [ mesh . is_boundary_node ] = 0.0 out = scipy . sparse . linalg . spsolve ( matrix , rhs ) return out | As discussed above the approximated Jacobian is |
56,097 | def quasi_newton_uniform ( points , cells , * args , ** kwargs ) : def get_new_points ( mesh ) : x = mesh . node_coords . copy ( ) cells = mesh . cells [ "nodes" ] jac_x = jac_uniform ( x , cells ) x -= solve_hessian_approx_uniform ( x , cells , jac_x ) return x mesh = MeshTri ( points , cells ) runner ( get_new_points , mesh , * args , ** kwargs ) return mesh . node_coords , mesh . cells [ "nodes" ] | Like linear_solve above but assuming rho == 1 . Note that the energy gradient |
56,098 | def fixed_point ( points , cells , * args , ** kwargs ) : def get_new_points ( mesh ) : num_neighbors = numpy . zeros ( len ( mesh . node_coords ) , dtype = int ) idx = mesh . edges [ "nodes" ] fastfunc . add . at ( num_neighbors , idx , numpy . ones ( idx . shape , dtype = int ) ) new_points = numpy . zeros ( mesh . node_coords . shape ) fastfunc . add . at ( new_points , idx [ : , 0 ] , mesh . node_coords [ idx [ : , 1 ] ] ) fastfunc . add . at ( new_points , idx [ : , 1 ] , mesh . node_coords [ idx [ : , 0 ] ] ) new_points /= num_neighbors [ : , None ] idx = mesh . is_boundary_node new_points [ idx ] = mesh . node_coords [ idx ] return new_points mesh = MeshTri ( points , cells ) runner ( get_new_points , mesh , * args , ** kwargs ) return mesh . node_coords , mesh . cells [ "nodes" ] | Perform k steps of Laplacian smoothing to the mesh i . e . moving each interior vertex to the arithmetic average of its neighboring points . |
56,099 | def energy ( mesh , uniform_density = False ) : dim = mesh . cells [ "nodes" ] . shape [ 1 ] - 1 star_volume = numpy . zeros ( mesh . node_coords . shape [ 0 ] ) for i in range ( 3 ) : idx = mesh . cells [ "nodes" ] [ : , i ] if uniform_density : fastfunc . add . at ( star_volume , idx , mesh . cell_volumes ) else : fastfunc . add . at ( star_volume , idx , numpy . ones ( idx . shape , dtype = float ) ) x2 = numpy . einsum ( "ij,ij->i" , mesh . node_coords , mesh . node_coords ) out = 1 / ( dim + 1 ) * numpy . dot ( star_volume , x2 ) assert dim == 2 x = mesh . node_coords [ : , : 2 ] triangles = numpy . moveaxis ( x [ mesh . cells [ "nodes" ] ] , 0 , 1 ) val = quadpy . triangle . integrate ( lambda x : x [ 0 ] ** 2 + x [ 1 ] ** 2 , triangles , quadpy . triangle . Dunavant ( 2 ) , ) if uniform_density : val = numpy . sum ( val ) else : rho = 1.0 / mesh . cell_volumes val = numpy . dot ( val , rho ) assert out >= val return out - val | The mesh energy is defined as |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.