예제 #1
0
  /**
   * Adds a GenomeLoc to the collection, merging it if it overlaps another region. If it's not
   * overlapping then we add it in sorted order.
   *
   * @param e the GenomeLoc to add to the collection
   * @return true, if the GenomeLoc could be added to the collection
   */
  public boolean addRegion(GenomeLoc e) {
    if (e == null) {
      return false;
    }
    // have we added it to the collection?
    boolean haveAdded = false;

    /**
     * check if the specified element overlaps any current locations, if so we should merge the two.
     */
    for (GenomeLoc g : mArray) {
      if (g.contiguousP(e)) {
        GenomeLoc c = g.merge(e);
        mArray.set(mArray.indexOf(g), c);
        haveAdded = true;
      } else if ((g.getContigIndex() == e.getContigIndex())
          && (e.getStart() < g.getStart())
          && !haveAdded) {
        mArray.add(mArray.indexOf(g), e);
        return true;
      } else if (haveAdded
          && ((e.getContigIndex() > e.getContigIndex())
              || (g.getContigIndex() == e.getContigIndex() && e.getStart() > g.getStart()))) {
        return true;
      }
    }
    /**
     * we're at the end and we haven't found locations that should fall after it, so we'll put it at
     * the end
     */
    if (!haveAdded) {
      mArray.add(e);
    }
    return true;
  }
 @Override
 public int compareTo(final Card card) {
   if (value.equals(card.value)) {
     return DEUCE;
   }
   final int cardValue = CARDS_VALUES.indexOf(value);
   final int rhsCardValue = CARDS_VALUES.indexOf(card.value);
   return cardValue > rhsCardValue ? PLAYER_ONE : PLAYER_TWO;
 }
예제 #3
0
 public static void main(String[] args) {
   Random rand = new Random(47);
   List<Pet> pets = Pets.arrayList(7);
   print("1: " + pets);
   Hamster h = new Hamster();
   pets.add(h); // Automatically resizes
   print("2: " + pets);
   print("3: " + pets.contains(h));
   pets.remove(h); // Remove by object
   Pet p = pets.get(2);
   print("4: " + p + " " + pets.indexOf(p));
   Pet cymric = new Cymric();
   print("5: " + pets.indexOf(cymric));
   print("6: " + pets.remove(cymric));
   // Must be the exact object:
   print("7: " + pets.remove(p));
   print("8: " + pets);
   pets.add(3, new Mouse()); // Insert at an index
   print("9: " + pets);
   List<Pet> sub = pets.subList(1, 4);
   print("subList: " + sub);
   print("10: " + pets.containsAll(sub));
   Collections.sort(sub); // In-place sort
   print("sorted subList: " + sub);
   // Order is not important in containsAll():
   print("11: " + pets.containsAll(sub));
   Collections.shuffle(sub, rand); // Mix it up
   print("shuffled subList: " + sub);
   print("12: " + pets.containsAll(sub));
   List<Pet> copy = new ArrayList<Pet>(pets);
   sub = Arrays.asList(pets.get(1), pets.get(4));
   print("sub: " + sub);
   copy.retainAll(sub);
   print("13: " + copy);
   copy = new ArrayList<Pet>(pets); // Get a fresh copy
   copy.remove(2); // Remove by index
   print("14: " + copy);
   copy.removeAll(sub); // Only removes exact objects
   print("15: " + copy);
   copy.set(1, new Mouse()); // Replace an element
   print("16: " + copy);
   copy.addAll(2, sub); // Insert a list in the middle
   print("17: " + copy);
   print("18: " + pets.isEmpty());
   pets.clear(); // Remove all elements
   print("19: " + pets);
   print("20: " + pets.isEmpty());
   pets.addAll(Pets.arrayList(4));
   print("21: " + pets);
   Object[] o = pets.toArray();
   print("22: " + o[3]);
   Pet[] pa = pets.toArray(new Pet[0]);
   print("23: " + pa[3].id());
 }
 // MrBayes 的从页面读取参数的设置值
 static String getParametersFromRequestMrBayes(HttpServletRequest request) {
   StringBuffer re = new StringBuffer();
   Enumeration parameterNames = request.getParameterNames();
   List paraList = new MultipleAlignmentDefaultDAO().getParameterList(MRBAYESTYPE);
   StringBuffer[] paraSetList = new StringBuffer[paraList.size()];
   for (int len = 0; len < paraSetList.length; len++) {
     paraSetList[len] = new StringBuffer();
   }
   while (parameterNames.hasMoreElements()) {
     String paraName = (String) parameterNames.nextElement();
     String[] paraValues = paraName.split(SEPERATEPARANAME);
     if (paraValues.length == 2) {
       int index = paraList.indexOf(paraValues[0]);
       if (index != -1) {
         String paraValue = (String) request.getParameter(paraName);
         if (!"".equals(paraValue) && null != paraValue) {
           paraSetList[index].append(
               paraValues[1] + SEPERATEPARAMETERANDVALUE + paraValue + SEPERATEPARAMETERS);
         }
       }
     }
   }
   for (int len = 0; len < paraSetList.length; len++) {
     if (paraSetList[len].length() > 0) {
       paraSetList[len].deleteCharAt(paraSetList[len].length() - 1);
       re.append(new StringBuffer((String) paraList.get(len)));
       re.append(SEPERATEPARAMETERS).append(paraSetList[len]).append(";");
     } else {
       re.append(new StringBuffer((String) paraList.get(len)));
       re.append(";");
     }
   }
   return re.toString();
 }
예제 #5
0
    /** {@inheritDoc} */
    protected void encounterVertexAgain(V vertex, E edge) {
      super.encounterVertexAgain(vertex, edge);

      int i;

      if (root != null) {
        // For rooted detection, the path must either
        // double back to the root, or to a node of a cycle
        // which has already been detected.
        if (vertex.equals(root)) {
          i = 0;
        } else if ((cycleSet != null) && cycleSet.contains(vertex)) {
          i = 0;
        } else {
          return;
        }
      } else {
        i = path.indexOf(vertex);
      }

      if (i > -1) {
        if (cycleSet == null) {
          // we're doing yes/no cycle detection
          throw new CycleDetectedException();
        } else {
          for (; i < path.size(); ++i) {
            cycleSet.add(path.get(i));
          }
        }
      }
    }
예제 #6
0
  /**
   * Adds a picture to the workbook.
   *
   * @param pictureData The bytes of the picture
   * @param format The format of the picture.
   * @return the index to this picture (1 based).
   * @see XSLFPictureData#PICTURE_TYPE_EMF
   * @see XSLFPictureData#PICTURE_TYPE_WMF
   * @see XSLFPictureData#PICTURE_TYPE_PICT
   * @see XSLFPictureData#PICTURE_TYPE_JPEG
   * @see XSLFPictureData#PICTURE_TYPE_PNG
   * @see XSLFPictureData#PICTURE_TYPE_DIB
   */
  public int addPicture(byte[] pictureData, int format) {
    XSLFPictureData img = findPictureData(pictureData);
    POIXMLRelation relDesc = XSLFPictureData.RELATIONS[format];

    if (img == null) {
      int imageNumber = _pictures.size();
      img =
          (XSLFPictureData)
              createRelationship(
                  XSLFPictureData.RELATIONS[format],
                  XSLFFactory.getInstance(),
                  imageNumber + 1,
                  true);
      _pictures.add(img);
      try {
        OutputStream out = img.getPackagePart().getOutputStream();
        out.write(pictureData);
        out.close();
      } catch (IOException e) {
        throw new POIXMLException(e);
      }
      return _pictures.size() - 1;
    } else {
      return _pictures.indexOf(img);
    }
  }
예제 #7
0
  public void changeEdgeNode(int direction, StatEdge edge, Statement value) {

    Map<Integer, List<StatEdge>> mapEdges =
        direction == DIRECTION_BACKWARD ? mapPredEdges : mapSuccEdges;
    Map<Integer, List<Statement>> mapStates =
        direction == DIRECTION_BACKWARD ? mapPredStates : mapSuccStates;

    int type = edge.getType();

    int[] arrtypes;
    if (type == StatEdge.TYPE_EXCEPTION) {
      arrtypes = new int[] {STATEDGE_ALL, StatEdge.TYPE_EXCEPTION};
    } else {
      arrtypes = new int[] {STATEDGE_ALL, STATEDGE_DIRECT_ALL, type};
    }

    for (int edgetype : arrtypes) {
      List<StatEdge> lst = mapEdges.get(edgetype);
      if (lst != null) {
        int index = lst.indexOf(edge);
        if (index >= 0) {
          mapStates.get(edgetype).set(index, value);
        }
      }
    }

    if (direction == DIRECTION_BACKWARD) {
      edge.setSource(value);
    } else {
      edge.setDestination(value);
    }
  }
예제 #8
0
 public RexNode parameter(ParameterExpression param) {
   int i = parameterList.indexOf(param);
   if (i >= 0) {
     return values.get(i);
   }
   throw new RuntimeException("unknown parameter " + param);
 }
예제 #9
0
  /**
   * Build the encodings against each categorical feature.
   *
   * @return a list of encodings - last value of the list represent the encodings for the response
   *     variable. index - index of the feature value - Map<String, Integer> - map of unique values
   *     of this feature and there encoded values. key - unique value value - encoded value
   */
  private static List<Map<String, Integer>> buildEncodings(
      List<Feature> features,
      Map<String, String> summaryStats,
      List<Integer> newToOldIndicesList,
      int responseIndex) {
    List<Map<String, Integer>> encodings = new ArrayList<Map<String, Integer>>();
    for (int i = 0; i < newToOldIndicesList.size() + 1; i++) {
      encodings.add(new HashMap<String, Integer>());
    }
    for (Feature feature : features) {
      Map<String, Integer> encodingMap = new HashMap<String, Integer>();
      if (feature.getType().equals(FeatureType.CATEGORICAL)) {
        List<String> uniqueVals =
            getUniqueValues(feature.getIndex(), summaryStats.get(feature.getName()));
        Collections.sort(uniqueVals);
        for (int i = 0; i < uniqueVals.size(); i++) {
          encodingMap.put(uniqueVals.get(i), i);
        }
        int newIndex = newToOldIndicesList.indexOf(feature.getIndex());
        if (newIndex != -1) {
          encodings.set(newIndex, encodingMap);
        } else if (feature.getIndex() == responseIndex) {
          // response encoding at the end
          encodings.set(encodings.size() - 1, encodingMap);
        }
      }
    }

    return encodings;
  }
 public static void loadDescriptors(
     String pluginsPath,
     List<IdeaPluginDescriptorImpl> result,
     @Nullable StartupProgress progress,
     int pluginsCount) {
   final File pluginsHome = new File(pluginsPath);
   final File[] files = pluginsHome.listFiles();
   if (files != null) {
     int i = result.size();
     for (File file : files) {
       final IdeaPluginDescriptorImpl descriptor = loadDescriptor(file, PLUGIN_XML);
       if (descriptor == null) continue;
       if (progress != null) {
         progress.showProgress(
             descriptor.getName(), PLUGINS_PROGRESS_MAX_VALUE * ((float) ++i / pluginsCount));
       }
       int oldIndex = result.indexOf(descriptor);
       if (oldIndex >= 0) {
         final IdeaPluginDescriptorImpl oldDescriptor = result.get(oldIndex);
         if (StringUtil.compareVersionNumbers(oldDescriptor.getVersion(), descriptor.getVersion())
             < 0) {
           result.set(oldIndex, descriptor);
         }
       } else {
         result.add(descriptor);
       }
     }
   }
 }
예제 #11
0
파일: Projection.java 프로젝트: cns-iu/nwb
 public Tuple query(Object... keys) {
   Object key = keys[0];
   if (labels.contains(key)) {
     return PrototypedTuple.singleton(labels.indexOf(key));
   }
   return PrototypedTuple.singleton(null);
 }
예제 #12
0
 /**
  * Build a string representing a sequence of method calls needed to reach a particular child
  * method.
  *
  * @param allMethods previous method call sequence
  * @param newMethods names of each of the methods in callingMethods
  * @param callingMethods MethodEntry objects for each method
  * @param currentMethod current method being handled
  * @param rms contains setting determining if depth-first or breadth-first traversal has taken
  *     place.
  * @return
  */
 private String appendMN(
     String allMethods,
     String[] newMethods,
     List callingMethods,
     MethodEntry currentMethod,
     RelatedMethodsSettings rms) {
   StringBuffer result = new StringBuffer(allMethods.length() + 80);
   result.append(allMethods);
   if (rms.isDepthFirstOrdering()) {
     if (newMethods.length > 0) {
       if (result.length() > 0) result.append('.');
     }
     int index = callingMethods.indexOf(currentMethod);
     result.append(newMethods[index]);
     result.append("()");
   } else {
     if (newMethods.length > 0) {
       if (result.length() > 0) result.append('.');
       if (newMethods.length > 1) {
         result.append('[');
       }
       for (int i = 0; i < newMethods.length; i++) {
         if (i > 0) result.append(',');
         result.append(newMethods[i]);
         result.append("()");
       }
       if (newMethods.length > 1) {
         result.append(']');
       }
     }
   }
   return result.toString();
 }
예제 #13
0
  /*
   * Match CodeSource to a CodeSigner[] in the signer cache.
   */
  private CodeSigner[] findMatchingSigners(CodeSource cs) {
    if (cs instanceof VerifierCodeSource) {
      VerifierCodeSource vcs = (VerifierCodeSource) cs;
      if (vcs.isSameDomain(csdomain)) {
        return ((VerifierCodeSource) cs).getPrivateSigners();
      }
    }

    /*
     * In practice signers should always be optimized above
     * but this handles a CodeSource of any type, just in case.
     */
    CodeSource[] sources = mapSignersToCodeSources(cs.getLocation(), getJarCodeSigners(), true);
    List sourceList = new ArrayList();
    for (int i = 0; i < sources.length; i++) {
      sourceList.add(sources[i]);
    }
    int j = sourceList.indexOf(cs);
    if (j != -1) {
      CodeSigner[] match;
      match = ((VerifierCodeSource) sourceList.get(j)).getPrivateSigners();
      if (match == null) {
        match = emptySigner;
      }
      return match;
    }
    return null;
  }
예제 #14
0
  public static void main(String[] args) {
    List<String> list = new ArrayList<String>();

    Collections.addAll(list, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J");
    System.out.println(list);
    System.out.println("list.subList(3,8): " + list.subList(3, 8));
    System.out.println("list.subList(3,8).get(2): " + list.subList(3, 8).get(2));

    System.out.println("list.subList(3,8).set(2,\"B\"):");
    list.subList(3, 8).set(2, "B");
    System.out.println(list);
    System.out.println("list.indexOf(\"B\"): " + list.indexOf("B"));
    System.out.println("list.subList(3,8).indexOf(\"B\"): " + list.subList(3, 8).indexOf("B"));
    System.out.println(list);
    System.out.println("Collections.reverse(list.subList(3,8)):");
    Collections.reverse(list.subList(3, 8));
    System.out.println(list);
    System.out.println("Collections.rotate(list.subList(3,8), 2):");
    Collections.rotate(list.subList(3, 8), 2);
    System.out.println(list);
    System.out.println("Collections.fill(list.subList(3,8), \"X\"):");
    Collections.fill(list.subList(3, 8), "X");
    System.out.println(list);
    list.subList(3, 8).clear();
    System.out.println(list);
  }
예제 #15
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.jface.wizard.IWizard#getPreviousPage(org.eclipse.jface.wizard
  * .IWizardPage)
  */
 public IWizardPage getPreviousPage(IWizardPage page) {
   int index = pages.indexOf(page);
   if (index == 0 || index == -1)
     // first page or page not found
     return null;
   return (IWizardPage) pages.get(index - 1);
 }
예제 #16
0
      void reduce(Entry otherEntry, Sort sort) {
        assert text.equals(otherEntry.text);
        assert offset == otherEntry.offset;
        assert length == otherEntry.length;

        for (Option otherOption : otherEntry.options) {
          int index = options.indexOf(otherOption);
          if (index >= 0) {
            Option thisOption = options.get(index);
            thisOption.setFreq(thisOption.freq + otherOption.freq);
          } else {
            options.add(otherOption);
          }
        }

        Comparator<Option> comparator;
        switch (sort) {
          case SCORE:
            comparator = SuggestPhase.SCORE;
            break;
          case FREQUENCY:
            comparator = SuggestPhase.FREQUENCY;
            break;
          default:
            throw new ElasticSearchException("Could not resolve comparator in reduce phase.");
        }
        Collections.sort(options, comparator);
      }
예제 #17
0
  /** helper: process a <code>&lt;classpath&gt;</code> tag. */
  private void changeClassPath(List<String> classpath, IXMLElement child) throws Exception {
    String add = child.getAttribute("add");
    if (add != null) {
      add = this.vs.substitute(add, SubstitutionType.TYPE_PLAIN);
      if (!new File(add).exists()) {
        if (!this.handler.emitWarning(
            "Invalid classpath",
            "The path " + add + " could not be found.\nCompilation may fail.")) {
          throw new Exception("Classpath " + add + " does not exist.");
        }
      } else {
        classpath.add(this.vs.substitute(add, SubstitutionType.TYPE_PLAIN));
      }
    }

    String sub = child.getAttribute("sub");
    if (sub != null) {
      int cpidx = -1;
      sub = this.vs.substitute(sub, SubstitutionType.TYPE_PLAIN);

      do {
        cpidx = classpath.indexOf(sub);
        classpath.remove(cpidx);
      } while (cpidx >= 0);
    }
  }
예제 #18
0
  /**
   * Encode the CertPath using PKIPATH format.
   *
   * @return a byte array containing the binary encoding of the PkiPath object
   * @exception CertificateEncodingException if an exception occurs
   */
  private byte[] encodePKIPATH() throws CertificateEncodingException {

    ListIterator<X509Certificate> li = certs.listIterator(certs.size());
    try {
      DerOutputStream bytes = new DerOutputStream();
      // encode certs in reverse order (trust anchor to target)
      // according to PkiPath format
      while (li.hasPrevious()) {
        X509Certificate cert = li.previous();
        // check for duplicate cert
        if (certs.lastIndexOf(cert) != certs.indexOf(cert)) {
          throw new CertificateEncodingException("Duplicate Certificate");
        }
        // get encoded certificates
        byte[] encoded = cert.getEncoded();
        bytes.write(encoded);
      }

      // Wrap the data in a SEQUENCE
      DerOutputStream derout = new DerOutputStream();
      derout.write(DerValue.tag_SequenceOf, bytes);
      return derout.toByteArray();

    } catch (IOException ioe) {
      throw new CertificateEncodingException("IOException encoding " + "PkiPath data: " + ioe, ioe);
    }
  }
예제 #19
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.jface.wizard.IWizard#getNextPage(org.eclipse.jface.wizard
   * .IWizardPage)
   */
  public IWizardPage getNextPage(IWizardPage page) {
    int index = pages.indexOf(page);
    if (index == pages.size() - 1 || index == -1)
      // last page or page not found
      return null;

    return (IWizardPage) pages.get(index + 1);
  }
예제 #20
0
 private void removePlayer(Player player) {
   int index = players.indexOf(player);
   if (index < 0) return;
   players.remove(index);
   Game game = games.remove(index);
   removeController(player, index);
   game.destroy();
 }
예제 #21
0
 @Override
 public int getSectionForPosition(int position) {
   SectionAndItem<T> sectionAndItem = getSectionAndItem(position);
   if (sectionAndItem != null && sectionAndItem.getType() != SectionAndItem.Type.ACTIVITY_CIRCLE) {
     return Math.max(
         0, Math.min(sectionKeys.indexOf(sectionAndItem.sectionKey), sectionKeys.size() - 1));
   }
   return 0;
 }
  private static void writeView(View view, JsonObject json) {
    writeString("viewType", view.getClass().getCanonicalName(), json);

    writeString("viewName", view.getViewName(), json);

    writeString("generator", view.getViewGenerator(), json);

    if (view.getScore() != 0) writeDouble("score", view.getScore(), json);

    List<Constituent> constituents = view.getConstituents();

    if (constituents.size() > 0) {
      JsonArray cJson = new JsonArray();
      for (int i = 0; i < view.getNumberOfConstituents(); i++) {

        Constituent constituent = constituents.get(i);
        JsonObject c = new JsonObject();
        writeConstituent(constituent, c);

        cJson.add(c);
      }

      json.add("constituents", cJson);
    }

    List<Relation> relations = view.getRelations();

    if (relations.size() > 0) {

      JsonArray rJson = new JsonArray();

      for (Relation r : relations) {
        Constituent src = r.getSource();
        Constituent tgt = r.getTarget();

        int srcId = constituents.indexOf(src);
        int tgtId = constituents.indexOf(tgt);

        JsonObject rJ = new JsonObject();

        writeString("relationName", r.getRelationName(), rJ);

        if (r.getScore() != 0) writeDouble("score", r.getScore(), rJ);
        writeInt("srcConstituent", srcId, rJ);
        writeInt("targetConstituent", tgtId, rJ);
        writeAttributes(r, rJ);

        Map<String, Double> labelsToScores = r.getLabelsToScores();

        if (null != labelsToScores) writeLabelsToScores(labelsToScores, rJ);

        rJson.add(rJ);
      }

      json.add("relations", rJson);
    }
  }
 /**
  * {@collect.stats} Changes the current element of the sequence and notifies <code>ChangeListeners
  * </code>. If the specified value is not equal to an element of the underlying sequence then an
  * <code>IllegalArgumentException</code> is thrown. In the following example the <code>setValue
  * </code> call would cause an exception to be thrown:
  *
  * <pre>
  * String[] values = {"one", "two", "free", "four"};
  * SpinnerModel model = new SpinnerListModel(values);
  * model.setValue("TWO");
  * </pre>
  *
  * @param elt the sequence element that will be model's current value
  * @throws IllegalArgumentException if the specified value isn't allowed
  * @see SpinnerModel#setValue
  * @see #getValue
  */
 public void setValue(Object elt) {
   int index = list.indexOf(elt);
   if (index == -1) {
     throw new IllegalArgumentException("invalid sequence element");
   } else if (index != this.index) {
     this.index = index;
     fireStateChanged();
   }
 }
예제 #24
0
 private static ConfigurationBase getInstance(ConfigurationBase configurationBase) {
   int index;
   if ((index = instances.indexOf(configurationBase)) == -1) {
     instances.add(configurationBase);
     return configurationBase;
   } else {
     return instances.get(index);
   }
 }
예제 #25
0
 public static <T extends DomElement> T addElementAfter(@NotNull final T anchor) {
   final DomElement parent = anchor.getParent();
   final DomCollectionChildDescription childDescription =
       (DomCollectionChildDescription) anchor.getChildDescription();
   assert parent != null;
   final List<? extends DomElement> list = childDescription.getValues(parent);
   final int i = list.indexOf(anchor);
   assert i >= 0;
   return (T) childDescription.addValue(parent, i + 1);
 }
  /**
   * Removes an object from the collection of choices.
   *
   * @param object The object to be removed
   */
  public void remove(T object) {
    int index = choices.indexOf(object);

    total -= currentFreqs.get(index);
    choices.remove(index);
    baseFreqs.remove(index);
    currentFreqs.remove(index);

    while (pregenerated.remove(object)) /* nothing inside loop */ ;
  }
예제 #27
0
  /**
   * Creates a map from the ChEBI Compounds resources of secondary to primary parentMap.
   *
   * @throws IOException problem reading file
   * @throws MissingLocationException if ChEBI Compounds resource location is missing
   */
  public void createMap() throws IOException, MissingLocationException {

    ResourceFileLocation location = getLocation("ChEBI Compounds");
    CSVReader csv = new CSVReader(new InputStreamReader(location.open()), '\t');

    List<String> header = Arrays.asList(csv.readNext());
    int accessionIndex = header.indexOf("CHEBI_ACCESSION");
    int parentIndex = header.indexOf("PARENT_ID");
    int statusIndex = header.indexOf("STATUS");

    Pattern NULL_PATTERN = Pattern.compile("null");
    Pattern ACCESSION_PATTERN = Pattern.compile("(?:C[hH]EBI:)?(\\d+)");

    String[] row = null;
    while ((row = csv.readNext()) != null) {

      String accession = row[accessionIndex];
      String parent = row[parentIndex];
      Character status = row[statusIndex].charAt(0);

      Matcher accessionMatcher = ACCESSION_PATTERN.matcher(accession);
      Matcher parentMatcher = ACCESSION_PATTERN.matcher(parent);

      if (accessionMatcher.find()) {

        String childAcc = accessionMatcher.group(1);
        String parentAcc = parentMatcher.find() ? parentMatcher.group(1) : childAcc;

        childMap.put(parentAcc, "CHEBI:" + childAcc);
        childMap.put("CHEBI:" + parentAcc, "CHEBI:" + childAcc);

        parentMap.put(childAcc, "CHEBI:" + parentAcc);
        parentMap.put("CHEBI:" + childAcc, "CHEBI:" + parentAcc);

        statusMap.put(childAcc, status);
        statusMap.put("CHEBI:" + childAcc, status);
      }
    }

    location.close();
    csv.close();
  }
  private void loadBondedParams() {
    String fileName = "res/amber03/ffbonded.itp";
    List<String> fileAsList = FileReader.readFile(fileName);
    int bondtypes = fileAsList.indexOf("[ bondtypes ]");
    int constrainttypes = fileAsList.indexOf("[ constrainttypes ]");
    int angletypes = fileAsList.indexOf("[ angletypes ]");
    int improperDihedral = fileAsList.indexOf("[ dihedraltypes ]");
    int properDihedral = fileAsList.lastIndexOf("[ dihedraltypes ]");

    //		System.out.println(bondtypes);
    //		System.out.println(constrainttypes);
    //		System.out.println(angletypes);
    //		System.out.println(improperDihedral);
    //		System.out.println(properDihedral);

    loadBondParams(fileAsList.subList(bondtypes + 1, constrainttypes));
    loadAngleParams(fileAsList.subList(angletypes + 1, improperDihedral));
    loadImproperDihedralParams(fileAsList.subList(improperDihedral + 1, properDihedral));
    loadProperDihedralParams(fileAsList.subList(properDihedral + 1, fileAsList.size()));
  }
예제 #29
0
 /**
  * Writes this state to the given output stream.
  *
  * @param dos the data output stream
  * @throws IOException if an error occurs
  */
 public void writeBinary(DataOutputStream dos) throws IOException {
   dos.writeInt(TYPE);
   if (phoneList == null) {
     dos.writeInt(0);
   } else {
     dos.writeInt(phoneList.length);
     for (int i = 0; i < phoneList.length; i++) {
       dos.writeInt(phonemeTable.indexOf(phoneList[i]));
     }
   }
 }
 public void insertAfter(@NotNull String key, @NotNull String value, @NotNull String anchor) {
   if (myAlphaSorted || !myOrdered) {
     throw new IllegalStateException(
         "Can't insert new properties by anchor while resource bundle is alpha-sorted");
   }
   final PropertiesFile file = myResourceBundle.getDefaultPropertiesFile();
   final IProperty anchorProperty = file.findPropertyByKey(anchor);
   file.addPropertyAfter(key, value, anchorProperty);
   final int anchorIndex = myKeysOrder.indexOf(anchor);
   myKeysOrder.add(anchorIndex + 1, key);
 }