private static AtomCache initializeCache() {
   AtomCache cache = new AtomCache();
   cache.setUseMmCif(true);
   FileParsingParameters params = cache.getFileParsingParams();
   params.setStoreEmptySeqRes(true);
   params.setAlignSeqRes(true);
   // params.setParseCAOnly(true);
   params.setLoadChemCompInfo(true);
   params.setCreateAtomBonds(false);
   cache.setFileParsingParams(params);
   ChemCompGroupFactory.setChemCompProvider(new AllChemCompProvider());
   //		ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider());
   return cache;
 }
  public static void main(String[] args) throws IOException {
    String timeStamp =
        new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());

    String uri = args[0] + "_" + timeStamp + ".seq";

    Set<String> pdbIds = getAll();

    StructureIO.setAtomCache(cache);
    cache.setPath("/Users/Chris/Documents/RCSB/Data/Protein_chains/cache/");

    long start = System.nanoTime();
    toSequenceFile(uri, pdbIds, true);
    long end = System.nanoTime();

    System.out.println("Time: " + (end - start) / 1E9 + " sec.");
  }
Пример #3
0
  /**
   * Returns the file name of the input structure: if user job it returns the path to the file in
   * the job dir, if precomputed it finds the file path in the local atom cache and creates a
   * symbolic link to it in the job dir
   *
   * @param directory Directory to search for the file
   * @param inputName either the input file name, or a PDB code
   * @param atomCachePath Path for downloaded CIF files
   * @return the path to the AU structure file in the job dir
   * @throws IOException if file is a user job file and can't be found, or if the input is a pdb id
   *     and its file can't be found in atom cache
   */
  public static File getAuFileName(File directory, String inputName, String atomCachePath)
      throws IOException {

    // inputName will be the full file name in user jobs and the pdbId for precomputed jobs
    File structFile = new File(directory, inputName);
    logger.info(
        "Trying to find the structure file for input name '{}'. Searching file in {}",
        inputName,
        structFile.toString());

    if (!structFile.exists()) {
      if (!inputName.matches("^\\d\\w\\w\\w$")) {
        throw new IOException(
            String.format(
                "Could not find file %s and the inputName '%s' does not look "
                    + "like a PDB id. Can't produce the lattice graph page!",
                structFile, inputName));
      } else {

        // it is like a PDB id, leave it to AtomCache
        AtomCache atomCache = null;
        if (atomCachePath == null) {
          atomCache = new AtomCache();
          logger.warn(
              "Defaulting to downloading structures to {}. Please set the ATOM_CACHE_PATH property.",
              atomCache.getCachePath());
        } else {
          atomCache = new AtomCache(atomCachePath);
        }

        atomCache.setUseMmCif(true);

        structFile = LatticeGUI.getFile(atomCache, inputName);

        if (structFile == null || !structFile.exists()) {
          logger.error(
              "The structure file {} does not exist in atom cache! Will not be able to display lattice graph",
              structFile);
          throw new IOException("Structure file " + structFile + " does not exist in atom cache");
        }

        File sLink = new File(directory, structFile.getName());
        if (!sLink.exists()) {

          // TODO downloading symlinks don't work with current server configuration,
          // TODO for now resorting to copy: must fix server config and do it with symlinks!

          logger.info("Copying to {} from file {}", sLink.toString(), structFile.toString());
          Files.copy(structFile.toPath(), sLink.toPath());

          // we create a symbolic link to the file in the atomcache dir
          // logger.info("Creating symbolic link {} to file {}", sLink.toString(),
          // structFile.toString());
          // Files.createSymbolicLink(sLink.toPath(), structFile.toPath());
        }
        // and finally if no exception is thrown we return the symbolic link
        structFile = sLink;
      }
    }

    return structFile;
  }
Пример #4
0
  public void testOldSecOutput() throws Exception {

    String fileName = "/ce_1fdo.A_2iv2.X.out";
    InputStream inStream = this.getClass().getResourceAsStream(fileName);
    assertNotNull("Could not find file " + fileName + " in resource path. Config error?", inStream);
    String xml = StringManipulationHelper.convertStreamToString(inStream);

    AtomCache cache = new AtomCache();
    String name1 = "1FDO.A";
    String name2 = "2IV2.X";
    Atom[] ca1 = cache.getAtoms(name1);
    Atom[] ca2 = cache.getAtoms(name2);

    assertEquals(715, ca1.length);
    assertEquals(697, ca2.length);

    AFPChain afpChainOrig = AFPChainXMLParser.fromXML(xml, ca1, ca2);

    assertNotNull("Could not get AfpChain object from flat file!", afpChainOrig);

    assertEquals(
        "Could not find alignment string for prot 1",
        "MKKVVTVCPYCASGCKINLVVDNGKIVRAEAAQGKTNQGTLCLKGYYGWDFINDTQILTPRLKTPMIRRQRGGKLEPVSWDEALNYVAERLSAIKEKYGPDAIQTTGSSRGTGNETNYVMQKFARAVIGTNNVDCCARVUHGPSVA-----GLHQSVGNGAMSNAINEIDNTDLVFVFGYNPADSHPIVANHVINAKRNGAKIIVCDPRKIETARIADMHIALKNGSNIALLNAMGHVIIEENLYDKAFVASRTEGFEEYRKIVEGYTPESVEDITGVSASEIRQAARMYAQAKSAAILWGMGVTQFYQGVETVRSLTSLAMLTGNLGKPHAGVNPVRGQNNVQGACDMGALPDTYPGYQYVKDPANREKFAKAWGVESLPAHTGYRISELPHRAAHGEVRAAYIMGEDPLQTDAELSAVRKAFEDLELVIVQDIFMTKTASAADVILPSTSWGEHEGVFTAADRGFQRFFKAVEPKWDLKTDWQIISEIATRMGYPMHYNNTQEIWDELRHLCPDFYGATYEKMGELGFIQWPCRDTSDADQGTSYLFKEKFDTPNGLAQFFTCDWVAPIDKLTDEYPMVLSTVREVGHYSCRSMTGNCAALAALADEPGYAQINTEDAKRLGIEDEALVWVHSRKGKIITRAQVSDRPNKGAIYMTYQWWIGACNELVTENLSPITKTPEYKYCAVRVEPIADQRAAEQYVIDEYNKLKTRLREAALA",
        new String(afpChainOrig.getAlnseq1(), 0, afpChainOrig.getAlnLength()));
    assertEquals(
        "Could not find alignment string for prot 2",
        "MKKVVTVCPYCASGCKINLVVDNGKIVRAEAAQGKTNQGTLCLKGYYGWDFINDTQILTPRLKTPMIRRQRGGKLEPVSWDEALNYVAERLSAIKEKYGPDAIQTTGSSRGTGNETNYVMQKFARAVIGTNNVDCCAR-----VUHGPSVAGLHQSVGNGAMSNAINEIDNTDLVFVFGYNPADSHPIVANHVINAKRNGAKIIVCDPRKIETARIADMHIALKNGSNIALLNAMGHVIIEENLYDKAFVASRTEGFEEYRKIVEGYTPESVEDITGVSASEIRQAARMYAQAKSAAILWGMGVTQFYQGVETVRSLTSLAMLTGNLGKPHAGVNPVRGQNNVQGACDMGALPDTYPGYQYVKDPANREKFAKAWGVESLPAHTGYRISELPHRAAHGEVRAAYIMGEDPLQTDAELSAVRKAFEDLELVIVQDIFMTKTASAADVILPSTSWGEHEGVFTAADRGFQRFFKAVEPKWDLKTDWQIISEIATRMGYPMHYNNTQEIWDELRHLCPDFYGATYEKMGELGFIQWPCRDTSDADQGTSYLFKEKFDTPNGLAQFFTCDWVAPIDKLTDEYPMVLSTVREVGHYSCRSMTGNCAALAALADEPGYAQINTEDAKRLGIEDEALVWVHSRKGKIITRAQVSDRPNKGAIYMTYQWW------------------PEYKYCAVRVEPIADQRAAEQYVIDEYNKLKTRLREAALA",
        new String(afpChainOrig.getAlnseq2(), 0, afpChainOrig.getAlnLength()));

    // calc time is hardware dependent.... overwrite...
    afpChainOrig.setCalculationTime(-1);

    assertEquals(
        "alnLength is wrong! (" + afpChainOrig.getAfpChainLen() + ")",
        720,
        afpChainOrig.getAlnLength());
    assertEquals(
        "gapLength is wrong! (" + afpChainOrig.getGapLen() + ")", 28, afpChainOrig.getGapLen());

    // identity should be 0.9569
    assertTrue(
        "alinment ID is < 0.95 ! (" + afpChainOrig.getIdentity() + ")",
        afpChainOrig.getIdentity() > 0.95);
    assertTrue(
        "alignment ID is > 0.96 ! (" + afpChainOrig.getIdentity() + ")",
        afpChainOrig.getIdentity() < 0.96);

    String xmlComp = AFPChainXMLConverter.toXML(afpChainOrig, ca1, ca2);

    FlipAFPChainTest t = new FlipAFPChainTest();
    t.printFirstMismatch(xml, xmlComp);
    StringManipulationTestsHelper.assertEqualsIgnoreEndline(xml, xmlComp);
    StructureAlignment ce = StructureAlignmentFactory.getAlgorithm(CeMain.algorithmName);

    AFPChain afpChainNew = ce.align(ca1, ca2);
    afpChainNew.setCalculationTime(-1);
    afpChainNew.setName1(name1);
    afpChainNew.setName2(name2);

    String xmlNew = AFPChainXMLConverter.toXML(afpChainNew, ca1, ca2);

    StringManipulationTestsHelper.assertEqualsIgnoreEndline(xml, xmlNew);
  }