The aim of the RInChI project, in the same vein as InChI, is to create a unique data string to describe a reaction. Reaction InChIs, or RInChIs, are such data strings. They use the InChI software and from an rxn input file a RInChI can be created. The tools for doing this are below, and some helpful information is given in the help pages.

Python 2 and Python 3

Please note that the RInChI code only runs on Python 2. A Python 3 compatible version is under development.


RInChI Documentation 
Last modified 04/03/2015

Copyright 2012 C.H.G. Allen, 2015 B.R. Hammond

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http:www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    
Table of Contents
rinchi_add.py
rinchi_analyse.py
rinchi_rings.py
rinchi_databse.py
rinchi_search.py


rinchi_add.py
######################################

This script combines seperate RInChIs representing the steps of a multi-step
reaction into a total RInChI representing the overall reaction.

Sample use:
    ./rinchi_addition.py /some/path/steps.rinchi
    
The input RInChI file should contain the RInChIs representing the steps of the
reaction IN ORDER and seperated by line breaks.
"""

rinchi_analyse.py
######################################

Substance search:

    Invoked by having -seeker as the script's first agument.
    
    Sample use:
        ./rinchi_analysis -seeker /some/path/query.inchi
            /some/path/database.rinchi -options
        
    Options:
        -reactant
            Specifies searching for the query substance as a reactant.
        -product
            Specifies searching for the query substance as a product.
        -eq
            Specifies searching for the query substance as an equilibrium
            reagent.
        -agent
            Specifies searching for the query substance as a reaction agent;
            i.e. a substance present at the start and end of the reaction, like
            a catalyst or solvent.
        -list
            List the RInChIs found mathing the query.
            
    N.B. The options can be used in tandem (e.g. use -product and -eq to search
        for the query substance as either a product or equilibrium agent.
        Specifying none has the same effect as specifing them all.


Stereochemical Analysis:

    Invoked by having -stereochem as the script's first argument.
    
    Sample use:
        ./rinchi_analysis -stereochem /some/path/database.rinchi -options

    Options:
        -list
            List the RInChIs found.
        -wd
            Ignore undefined or omitted stereocentres.
        -sp2
            Only search for sp2 centres.
        -sp3
            Only search for sp3 centres.
        -pm
            Return stereochanges-per-molecule.
        -psm
            Return stereochanges-per-stereochemical-molecule.
        -search:n
            Return only those reactions which create n stereocentres.  Use
            negative n to search for reactions which destroy stereocentres.


Cyclic Analysis:

    Invoked by having -cyclic as the script's first argument.
    
    Sample use:
        ./rinchi_analysis -cyclic /some/path/database.rinchi -options

    Options:
        -list
            List the RInChIs found.
        -pm
            Return cyclic changes-per-molecule.
        -pcm
            Return cyclic changes-per-cyclic-molecule.
        -search:n
            Return only those reactions which create n rings.  Use negative n
            to search for reactions which destroy rings.
"""


rinchi_convert.py
######################################

RXNfile-to-RInChI conversion:

    Invoked by having -rxn2rinchi as the script's first agument.
    
    Sample use:
        ./rinchi_convert.py -rxn2rinchi /some/path/myrxnfile.rxn -options
        
    Options:
        -rauxinfo
            Generate and return RAuxInfo along with the RInChI.
        -longkey
            Generate and return the Long-RInChIKey along with the RInChI.
        -shortkey
            Generate and return the Short-RInChIKey along with the RInChI.
        -fout
            Save the output to disk, rather than printing to the terminal.


RInChI-to-RXNfile conversion:

    Invoked by having -rinchi2rxn as the script's first agument.

    Sample use:
        ./rinchi_convert.py -rinchi2rxn /some/path/myrinchi.rinchi -options
        
    Options:
        -stdout
            Print the RXNfile to the terminal, rather than saving to disk. 
        

RDfile-to-RInCHI conversion:

    Invoked by having -rdf2rinchi as the script's first agument.
    
    Due to RDfiles often containing a great many RXN entries, this function
    always saves the RInChIs (and other outputs) to disk in the output folder.

    Sample use:
        ./rinchi_convert.py -rdf2rinchi /some/path/myrdfile.rdf -options
    
    Options:
        -rauxinfo
            Generate and return RAuxInfos along with the RInChIs.  These
            RAuxInfos will be saved to a seperate .rinchi file.
        -longkey
            Generate and return the Long-RInChIKeys along with the RInChIs.
            These RAuxInfos will be saved to a seperate .rinchi file.
        -shortkey
            Generate and return the Short-RInChIKeys along with the RInChIs.
            These RAuxInfos will be saved to a seperate .rinchi file.
        -begin:n
            Begin conversion at the nth RXN record.
        -end:m
            End conversion at the mth RXN record.     
"""


rinchi_rings.py
######################################

This script contains several new methods that can act on either individual 
RInchIs or collections of RInChIs. All calls to this script must begin with
one of the following arguments:
 -i		Process a single InChI
 -r		Process a single RInChI
 -b		Process a file containing multiple RInChIs

Ring Analysis:
	
 Invoked by using the --ringcount or --ringelements arguments. This script will 
 calculate the change in rings across a reaction. If supplied an InChI, the rings
 in that InChI will be returned. The --ringcount argument returns only the size
 of the rings, whereas --ringelements also returns the elemental composition
 of the rings, which is slightly slower to calculate. 
	
 Sample use:
  ./rinchi_rings.py -b --ringcount rinchis.rinchi
  ./rinchi_rings.py -r --ringcount [RInchI]
	
 Options:
  --list
   Along with the counter and the result, also return the RInChI for each
   entry.
  --quick
   Ignore reactions that do not have any change in rings according to
   rinchi_analyse. This will cause some reactions with well defined ring
   changes to be ignored, but will speed up processing time.

Ring Search:
 Invoked by using the --ringsearch argument. Accepts a list of RInChIs and a ring
 to search for, and returns each reaction in the list containing a change in the 
 given ring. The ring input is given in a SMILES like format, eg CCCCN for a 
 pyrrole or pyrrolidine ring.
	
 Sample use:
  ./rinchi_rings.py -b --ringsearch rinchis.rinchi CCO

 Options:
  --list
   Along with the counter and the result, also return the RInChI for each
   entry.
			
Change in Formula:
 Invoked by using the --formula argument. Accepts a rinchi or list of RInChIs and
 returns the change in chemical formula across the reaction. For a fully balanced
 equation, this change should be zero. 
	
 Sample use:
  ./rinchi_rings.py -b --formula rinchis.rinchi 

Presence of Isotopic Layers:
 Invoked by using the --isotopic argument. Accepts a list of RInChIs and returns 
 any that have a defined isotopic layer. This operation is very fast, and very few 
 RInChIs have defined isotopic layers.
	
 Sample use:
  ./rinchi_rings.py -b --isotopic rinchis.rinchi 
		
Change in carbon valence:
 Invoked by using the --valence argument. Accepts a rinchi or list of RInChIs and
 returns the change in valence of each carbon atom in the molecule. This script is
 experimental - valences for non-carbon elements are possible, but will not work
 for molecules with mobile hydrogen. 
	
 Sample use:
  ./rinchi_rings.py -b --valence rinchis.rinchi 

Change in carbon hybridisation:
 Invoked by using the --hybrid argument. Accepts a rinchi or list of RInChIs and
 returns the change in hybridisation of each carbon atom in the molecule. The 
 hybridisation scripts are not very useful alone, and are designed to be used
 in conjunction with other scripts in the RInChI software package.
	
 Sample use:
  ./rinchi_rings.py -b --hybrid rinchis.rinchi 
		

rinchi_database.py
######################################

RDF to CSV:
 Invoked by using the --rdf2csv argument. Accepts a single RDfile and converts it
 into a flat .CSV file containing A RInChI, and optionally the long RInChI key and 
 additional information. This script was created primarily for the purpose of 
 constructing the main RInChI database accessible at the RInChI website. 
	
 Sample use: 
  ./rinchi_database.py --rsf2csv in.rdf
		
		
Append an RDF to a CSV: 
 Invoked by the --rdfappend argument. Accepts an RDFile and a previously created CSV
 file, and attempts to append the contents of the RDfile to the CSV, matching the 
 existing layout of the CSV file. 
	
 Sample use: 
  ./rinchi_database.py --rsfappend in.rdf out.csv
		
		
RDF directory to a single CSV:
 Invoked by the --dir2csv argument. Accepts a directory and converts recursively 
 all the RDFiles found in the dirctory into a single flat CSV file, as above. Its 
 arguments are the directory to convert, and the desired output name of the csv,
	
 Sample use: 
  ./rinchi_database.py --dir2csv dir/ out.csv
		
		
SQL Database generation:
 Invoked by the --rdf2sql or --csv2sql arguments. Accepts a flat file, and the 
 filename of an Sqlite3 database. If the database does not exist, it will be created.
 The contents of the flat file are added to the database, including RInChI, long RInChI
 key, and auxinfo fields.
	
 Sample use: 
  ./rinchi_database.py --rdf2sql in.rdf database.db
  ./rinchi_database.py --csv2sql in.csv database.db

		
Fingerprint Generation:
 Invoked by the --ufingerprints argument. Accepts the name of a RInChI Sqlite database, 
 which must have first been given a table called fpts (TEXT, BLOB). This script creates 
 and stores a fingerprint for each reaction in the database. Will take a VERY long time
 if run over the entire database - reccomended that the SQL query is modified on each use
 using LIMIT/OFFSET parameters to ensure only entries that need to be updated are updated.
	
 Sample use: 
  ./rinchi_database.py --ufingerprints database.db

		
Fingerprint Recall:
 Invoked by the --rfingerprints argument. Accepts a RInChI Long Key and the name of a 
 database, and recalls the fingerprint belonging to that key, if any. 
	
 Sample use: 
  ./rinchi_database.py --rfingerprints [RInChI Key] database.db
		    

		
Fingerprint comparison:
 Invoked by the --cfingerprints argument. Accepts a RInChI or RInChI key, and a database.
 Compares the Euclidian distance beween the fingerprint of the input molecule and the 
 fingerprints stored in the database provided, and returns the top N most similar molecules
 to the input molecule. N is set to 10 by default, but can be easily changed. 
	
 Sample use: 
  ./rinchi_database.py --cfingerprints [RInChI] database.db
  ./rinchi_database.py --cfingerprints [RInChI Key] database.db
	

rinchi_search.py
######################################