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

📄 extension.java

📁 A program to find frequent molecular substructures and discriminative fragments in a database of mol
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      if (!this.checkRing())    /* check the structure of the ring */        continue;               /* and skip invalid rings */      if ((this.mode & EQVARS) != 0)        this.initVars();        /* init. variants of equiv. rings */      return true;              /* return "extension successful" */    }    return false;               /* return "extension failed" */  }  /* ring() */  /*------------------------------------------------------------------*/  protected boolean chain ()  {                             /* --- create a chain extension */    Atom a;                     /* to traverse the atoms of the chain */    Bond b;                     /* to traverse the bonds of the chain */    b = this.bonds[0];          /* get the starting bond */    if ((b.type != Bond.SINGLE) || !b.isBridge())      return false;             /* first bond must be single, bridge */    a = this.atoms[1];          /* get dest. atom (first in chain) */    while ((a.bondcnt == 2)     /* and traverse the carbon chain */    &&    ((a.type & Atom.TYPEMASK) == this.ccode)) {      b = a.bonds[(a.bonds[0] != b) ? 0 : 1];      if (b.mark < -1) return false;      if ((b.type != Bond.SINGLE) || !b.isBridge())        break;                  /* bond must be single and a bridge */      a = (a != b.src) ? b.src : b.dst;      this.size--;              /* go to the next bond and atom and */    }                           /* increase the carbon chain length */    if (this.size >= 0) {       /* if there is no carbon chain, */      this.size = -1; return false; }     /* abort the function */    this.bonds[1] = b;          /* note the last bond of the chain */    this.bdnew    = 2;          /* there are always two new bonds */    this.atoms[1] = a;          /* note the atom and its index */    this.atnew    = 1;          /* and set the new atom counter */    this.dst      = this.base.atoms.length;    this.chns = this.frag.chns +1; /* increment the chain counter */    return (this.base.atoms.length +this.chns +this.atnew <= this.max);  }  /* chain() */              /* return extension success */  /*------------------------------------------------------------------*/  protected int compareRing (Fragment frag)  {                             /* --- compare a ring extension */    int       i, k, na, nb;     /* loop variable, buffers */    int       t1, t2;           /* buffers for comparison */    Embedding emb;              /* to access an embedding */    Bond      b, x;             /* to traverse the bonds */    Atom      a, y;             /* to traverse the atoms */    emb = frag.list;            /* get an underlying embedding */    nb = emb.base.bonds.length; /* compare the number */    i  = emb.bonds.length -nb;  /* of added bonds */    if (this.bdnew < i) return -1;    if (this.bdnew > i) return +1;    na = emb.base.atoms.length; /* compare the number */    i  = emb.atoms.length -na;  /* of added atoms */    if (this.atnew < i) return -1;    if (this.atnew > i) return +1;    /* Note that the ring sizes must not be compared, because it is  */    /* possible that exactly the same extension (in terms of the set */    /* of new bonds and atoms) results from rings of different size, */    /* simply because the differing part is already in the fragment. */    for (i = k = 0; ++i < this.size; ) {      x = this.bonds[i];        /* traverse the remaining bonds */      if (x.mark >= 0) continue;/* skip already contained bonds */      a  = this.atoms[i];       /* get the source atom */      t1 = (a.mark >= 0) ? a.mark : na++;      t2 = frag.ris[k++];       /* get/compute source atom indices */      if (t1 < t2) return -1;   /* compare the indices */      if (t1 > t2) return +1;   /* of the source atoms */      y = emb.atoms[t2];        /* and then their types */      if (a.type < y.type) return -1;      if (a.type > y.type) return +1;      b = emb.bonds[++nb];      /* get the corresponding bond */      if (x.type < b.type) return -1;  /* compare the types */      if (x.type > b.type) return +1;  /* of the added bonds */      a  = this.atoms[(i+1) % this.size];      t1 = (a.mark >= 0) ? a.mark : na;      t2 = frag.ris[k++];       /* get/compute dest. atom indices */      if (t1 < t2) return -1;   /* compare the indices */      if (t1 > t2) return +1;   /* of the destination atoms */      y = emb.atoms[t2];        /* and then their types */      if (a.type < y.type) return -1;      if (a.type > y.type) return +1;    }                           /* (compare all added bonds) */    i = frag.ris[k++];          /* compare first insertion position */    if (this.pos1 < i) return -1;    if (this.pos1 > i) return +1;    i = frag.ris[k++];          /* compare second insertion position */    if (this.pos2 < i) return -1;    if (this.pos2 > i) return +1;    return 0;                   /* otherwise the fragments are equal */  }  /* compareRing() */  /*--------------------------------------------------------------------  The above function assumes that the first bond of the ring together  with its destination atom have already been compared (in the function  compareTo) and thus only compares the rest of the new ring bonds.  --------------------------------------------------------------------*/  protected void init (Molecule mol, int fixed)  {                             /* --- initialize for canonical form */    int k, n;                   /* number of atoms/bonds/characters */    k = mol.atomcnt;            /* enlarge atom vector if necessary */    if (k > this.atoms.length) this.atoms = new Atom[k];    k = mol.bondcnt;            /* enlarge bond vector if necessary */    if (k > this.bonds.length) this.bonds = new Bond[k];    n = (k << 2) +2;            /* enlarge code word if necessary */    if (n > this.word.length)  this.word  = new int[n];    this.word[n-1] = 0;         /* place a sentinel in the code word */    this.size      = k;         /* note the number of bonds and */    this.src       = fixed;     /* the number of fixed bonds */  }  /* init() */  /*------------------------------------------------------------------*/  protected int    makeWord    (Molecule mol)  { return this.makeWord(mol, mol.bondcnt); }  protected int    compareWord (Molecule mol)  { return this.compareWord(mol, mol.bondcnt); }  protected String makeString  (Molecule mol)  { return this.makeString(mol, true); }  /*------------------------------------------------------------------*/  public    abstract void    init        (Fragment frag,                                          Embedding base);  public    abstract boolean next        ();  protected abstract boolean checkRing   ();  protected abstract void    initVars    ();  protected abstract boolean variant     ();  public    abstract int     compareTo   (Fragment frag);  protected abstract boolean unclosable  (Fragment frag);  protected abstract boolean adaptRing   (Fragment frag);  protected abstract int     isCanonic   (int bdi, int ati, int cnt);  protected abstract boolean makeCanonic (int bdi, int ati, int cnt);  protected abstract int     makeWord    (Molecule mol, int bondcnt);  protected abstract int     compareWord (Molecule mol, int bondcnt);  protected abstract String  makeString  (Molecule mol, boolean create);  protected abstract int     compareBond (Bond b1, Bond b2, int next);}  /* class Extension */

⌨️ 快捷键说明

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