⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notation.java

📁 A program to find frequent molecular substructures and discriminative fragments in a database of mol
💻 JAVA
字号:
/*----------------------------------------------------------------------  File    : Notation.java  Contents: abstract class for molecule notations  Author  : Christian Borgelt  History : 12.08.2006 file created from file Molecule.java----------------------------------------------------------------------*/package moss;import java.io.IOException;/*--------------------------------------------------------------------*/public abstract class Notation {/*--------------------------------------------------------------------*/  /* --- instance variables --- */  protected String   desc;      /* description of a molecule */  protected int      pos;       /* index of of next character */  protected int[]    labels;    /* label to atom index map */  protected Molecule mol;       /* created molecule */  /*------------------------------------------------------------------*/  public Notation () { }  /*--------------------------------------------------------------------  General grammar for molecule descriptions:  Molecule ::= Atom Branch  Branch   ::= \epsilon             | Bond Atom  Branch             | Bond Label Branch             | "(" Branch ")" Branch  Atom     ::= Element LabelDef  LabelDef ::= \epsilon             | Label LabelDef  The definitions of the terms "Element", "Bond", and "Label" depend  on the chosen description language. For the SMILES language it is:  Element  ::= "[H]" | "[He]" | "[Li]" | "[Be]" | ...             | "B" | "C" | "N" | "O" | "F" | ...  Bond     ::= \epsilon | "-" | "=" | "#" | ":"  Label    ::= [0-9] | "%" [0-9] [0-9]  --------------------------------------------------------------------*/  protected static void mark (Atom a)  {                             /* --- mark visits of each atom */    int  i;                     /* loop variable */    Bond b;                     /* to traverse the bonds */    if (--a.mark < 0) return;   /* skip already processed atoms */    for (i = 0; i < a.bondcnt; i++) {      b = a.bonds[i];           /* traverse the unprocessed bonds */      if (b.mark != 0) continue;      b.mark = -1;              /* mark the bond as processed */      mark((b.src != a) ? b.src : b.dst);    }                           /* follow the bond and process */  }  /* mark() */               /* the atoms recursively */  /*--------------------------------------------------------------------  In the above function the marker of an atom is used to determine the  number of labels needed for an atom: 1 means that the atom has not  been visited yet, 0 means that it has been visited only once (and  thus needs no label) -n, n > 0, means that it has been visited n+1  times and therefore needs n labels (for n "backward connections").  --------------------------------------------------------------------*/  protected static void unmark (Atom a)  {                             /* --- unmark a connected component */    int  i;                     /* loop variable */    Bond b;                     /* to traverse the bonds */    if (a.mark < 0) return;     /* skip already processed atoms */    a.mark = -1;                /* unmark the atom */    for (i = 0; i < a.bondcnt; i++) {      b = a.bonds[i];           /* traverse the unprocessed bonds */      if (b.mark != 0) continue;      b.mark = -1;              /* mark the bond as processed */      unmark((b.src != a) ? b.src : b.dst);    }                           /* follow the bond and process */  }  /* unmark() */             /* the atoms recursively */  /*--------------------------------------------------------------------  With the above function a connected component is unmarked after  it has been formatted. The procedure is a simple depth-first search.  --------------------------------------------------------------------*/  public abstract Molecule parse  (String desc) throws IOException;  public abstract String   format (Molecule mol);  public abstract String   format (int type);}  /* class Notation */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -