Package: knext
KEGG NetworkX Topological (KNeXT) parserKNeXT downloads and parses Kyoto Encylopedia of Genes and Genomes
(KEGG) markup language files (KGML). This tool employs NetworkX's framework
to create gene-only networks, but mixed (gene, compound, pathway) networks
can also be generated. All output files are in TSV format. KNeXT also
retrieves a TXT file of node x-y axis coordinates for use in NetworkX's
graph visualization library, and it is able to convert KEGG IDs
into Uniprot and NCBI IDs. KNeXT also maximizes metadata information
through preserving each edge's information and adding gene, compound, and
pathway names if desired.UsagePrimary line: knext get-kgml [SPECIES_NAME]
  
  KEGG NetworkX Topological (KNeXT) parser uses the KEGG
  API to gather all KGML files for a single species. 
  Input species name in 3 to 4 letter KEGG organism code. 

Options:
  --help,	shows options and website for KEGG organism codes
  -d/--d,	directory in which to save output

Primary line: knext genes [Input]

  KNeXT parser deploy's NetworkX's
  framework to create gene-only representations of KGML files.
  Genes between compounds are propagated before compounds are dropped.

Options:
  Input	KGML file or folder of KGML files to parse
  -r/--results	file or folder where output should be stored	
  -g/--graphics	outputs TXT file of x-y axis coordinates
  -u/--unique	TSV file's genes have a terminal modifier
  -n/--names    TSV file includes a column with gene names
                Notice: adds to parsing time and internet connection required
  --help	shows options and file types

Primary line: knext mixed [Input]

  KNeXT parser creates mixed (genes, compounds, pathways)
  representations of KGML files.

Options:
  Input	KGML file or folder of KGML files to parse
  -r/--results	file or folder where output should be stored
  -g/--graphics	outputs TXT file of x-y axis coordinates
  -u/--unique	TSV file's genes have a terminal modifier
  -n/--names    TSV file includes a column with compound, gene, and pathway names
                Notice: adds to parsing time and internet connection required
  --help	shows options and file types

Primary line: knext convert [OPTIONS]
  
  KNeXT parser converts KEGG entry IDs in TSV output files into
  UniProt or NCBI IDs.

Options:
  file	PATH:	path to TSV file
  species	TEXT:	KEGG 3 to 4 letter organism code
  --uniprot	optional flag for output:	use if UniProt IDs are the desired output
  --unique	optional flag for output:	use if the TSV file has terminal modifiers
  --graphics	PATH:	graphics file
  --help	optional flag:	shows options

Options:
  folder	PATH:	path to folder containing TSV files         
  species	TEXT:	KEGG 3 to 4 letter organism code
  --uniprot	optional flag for output:         use if UniProt IDs are the desired output
  --unique	optional flag for output:         use if the TSV file has terminal modifiers   
  --graphics	PATH:       path to folder containing graphics files          
  --help	optional flag:            shows optionsFor example, KNeXT can obtain all KGML files for Homo sapiens:$knextget-kgmlhsaThe resulting output folder can be used to parse the files:$knextgeneskgml_hsa--graphicsThe resulting output folder can be used to convert the TSV files and graphics file:$knextconvertkegg_gene_network_hsahsa--graphicskegg_gene_network_hsaGraphics text file usageimport networkx as nximport pandas as pdimport json#ForfilesthathaveUniProtorKEGGIDsedges = pd.read_csv('edges.tsv', sep = '\t')file_header = open('graphics.txt').read()pos = json.loads(file_header)graph = nx.from_pandas_edgelist(edges, source = 'entry1', target = 'entry2')nx.draw(graph, pos = pos)#ForfilesthathaveNCBI-GeneIDs#Makesureyouareusingintegersinthepandasdataframeaswelledges = pd.read_csv('edges.tsv', sep = '\t')file_header = open('graphics.txt').read()pos = json.loads(file_header)pos = {int(key): items for key, items in d.items() if key.isdigit()}graph = nx.from_pandas_edgelist(edges, source = 'entry1', target = 'entry2')nx.draw(graph, pos = pos)InputsKNeXT only accepts KGML files downloaded fromKEGGThe output of which can be used in successive commands.
All input formatsmust bein TSV format.
Column names are mandatory and should not be changed.Example TSV file with KEGG ID'sentry1entry2typevaluenamehsa:100271927-98hsa:22800-12PPrel-->activationhsa:100271927-98hsa:22808-12PPrel-->activationhsa:100271927-98hsa:3265-12PPrel-->activationExample TSV file for uniprot conversion with--uniqueoutputentry1entry2typevaluenameQ9Y243-23O15111-59PPrel-->activationQ9Y243-23Q6GYQ0-240PPrel, PPrel--|,+pinhibition,phosphorylationQ9Y243-23O14920-59PPrel-->activationInstallationThe current release isv1.2.1Installation is via pip:$pipinstallknextRepo can be downloaded and installed throughpoetry:$gitclonehttps://github.com/everest/knext.git$cdknext$poetryshell$poetryinstall$poetryrunknext[get-kgml,genes,mixed,orconvert]RequirementsRequirements are:Python >= 3.9typerclickrequestspandasnumpynetworkxpathlibpytest