예제 #1
0
bool PDBFileWriter::writeAtomLine(int nserial, const ResidIndex &rindex,
                                  const char *resnam, char chainch,
                                  MolAtomPtr pa, qlib::PrintStream &prs)
{
  int resind = rindex.first;
  char inscode = rindex.second;
  LString atomnam = pa->getName().c_str();
  // atomnam = atomnam.toUpperCase();

  // conv ILE's CD name
  // (CD is converted to CD1 in PDBFileReader, so this should not occur)
  if (LChar::equals(resnam, "ILE") && atomnam.equals("CD"))
    atomnam = "CD1";

#ifdef QTL_CONV
  // conv nucl's prime to aster
  atomnam.replace('\'', '*');

  // convert THY's C5A to C5M
  if (LChar::equals(resnam, "THY") &&
      atomnam.equals("C5A")) {
    atomnam = "C5M";
  }

  // conv nucl name
  if (LChar::equals(resnam, "ADE")) {
    resnam = "  A";
  }
  else if (LChar::equals(resnam, "THY")) {
    resnam = "  T";
  }
  else if (LChar::equals(resnam, "GUA")) {
    resnam = "  G";
  }
  else if (LChar::equals(resnam, "CYT")) {
    resnam = "  C";
  }
  else if (LChar::equals(resnam, "URI")) {
    resnam = "  U";
  }
#endif

  LString shead;

  shead = LString::format("%5d ", nserial);

  // format atom name
  shead += formatAtomName(pa);

  shead += LString::format("%3s "
                           "%c"
                           "%4d"
                           "%c",
                           resnam,
                           chainch,
                           resind,
                           (inscode=='\0') ? ' ' : inscode);
                           
  //////////
  // output to the stream

  prs.print("ATOM  ");
  prs.print(shead);

  // Get atom position before applying xformMat, if xformMat is set
  Vector4D pos = pa->getRawPos();

  prs.formatln("   "
               "%8.3f"
               "%8.3f"
               "%8.3f"
               "%6.2f"
               "%6.2f"
               "          "
               "    ",
               pos.x(),
               pos.y(),
               pos.z(),
               pa->getOcc(),
               pa->getBfac());

  if (pa->hasAnIsoU()) {
    prs.print("ANISOU");
    prs.print(shead);

    int u11 = int(pa->getU(0,0) * 1.0e4);
    int u22 = int(pa->getU(1,1) * 1.0e4);
    int u33 = int(pa->getU(2,2) * 1.0e4);
    int u12 = int(pa->getU(0,1) * 1.0e4);
    int u13 = int(pa->getU(0,2) * 1.0e4);
    int u23 = int(pa->getU(1,2) * 1.0e4);

    prs.formatln(" "
                 " %6d"
                 " %6d"
                 " %6d"
                 " %6d"
                 " %6d"
                 " %6d"
                 "          ",
                 u11, u22, u33, u12, u13, u23);
  }

  return true;
}