test_class.file: singa-structure/src/test/java/bio/singa/structure/parser/pdb/structures/StructureWriterTest.java
test_class.identifier: StructureWriterTest
test_case.body: @Test
      void writeMMTFStructure() throws IOException {
  
          LocalPDBRepository localPDB = new LocalPDBRepository("/tmp/pdb", SourceLocation.OFFLINE_MMTF);
          Path path = localPDB.getPathForPdbIdentifier("1acj");
  
          OakStructure structure = (OakStructure) StructureParser.pdb()
                  .pdbIdentifier("1acj")
                  .parse();
          StructureWriter.writeMMTFStructure(structure, path);
  
          Structure reparsedStructure = StructureParser.local()
                  .localPdbRepository(localPDB)
                  .pdbIdentifier("1acj")
                  .parse();
  
          assertEquals(structure.getAllAtoms().size(), reparsedStructure.getAllAtoms().size());
          assertEquals(structure.getAllLigands().size(),reparsedStructure.getAllLigands().size());
      }
test_case.class_method_signature: StructureWriterTest.writeMMTFStructure()
test_case.full_signature: @Test void writeMMTFStructure()
test_case.identifier: writeMMTFStructure
test_case.invocations: getPathForPdbIdentifier parse pdbIdentifier pdb writeMMTFStructure parse pdbIdentifier localPdbRepository local assertEquals size getAllAtoms size getAllAtoms assertEquals size getAllLigands size getAllLigands
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void writeMMTFStructure()
focal_class.declarator: logger = LoggerFactory.getLogger(StructureWriter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(StructureWriter.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: singa-structure/src/main/java/bio/singa/structure/parser/pdb/structures/StructureWriter.java
focal_class.identifier: StructureWriter
focal_class.class_method_signature: StructureWriter.StructureWriter()
focal_class.full_signature: private  StructureWriter()
focal_class.identifier: StructureWriter
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  StructureWriter()
focal_class.class_method_signature: StructureWriter.writeLeafSubstructureContainer(LeafSubstructureContainer leafSubstructureContainer, Path outputPath)
focal_class.full_signature: public static void writeLeafSubstructureContainer(LeafSubstructureContainer leafSubstructureContainer, Path outputPath)
focal_class.identifier: writeLeafSubstructureContainer
focal_class.modifiers: public static
focal_class.parameters: (LeafSubstructureContainer leafSubstructureContainer, Path outputPath)
focal_class.return: void
focal_class.signature: void writeLeafSubstructureContainer(LeafSubstructureContainer leafSubstructureContainer, Path outputPath)
focal_class.class_method_signature: StructureWriter.writeLeafSubstructures(List<LeafSubstructure<?>> leafSubstructures, Path outputPath)
focal_class.full_signature: public static void writeLeafSubstructures(List<LeafSubstructure<?>> leafSubstructures, Path outputPath)
focal_class.identifier: writeLeafSubstructures
focal_class.modifiers: public static
focal_class.parameters: (List<LeafSubstructure<?>> leafSubstructures, Path outputPath)
focal_class.return: void
focal_class.signature: void writeLeafSubstructures(List<LeafSubstructure<?>> leafSubstructures, Path outputPath)
focal_class.class_method_signature: StructureWriter.writeStructure(OakStructure structure, Path outputPath)
focal_class.full_signature: public static void writeStructure(OakStructure structure, Path outputPath)
focal_class.identifier: writeStructure
focal_class.modifiers: public static
focal_class.parameters: (OakStructure structure, Path outputPath)
focal_class.return: void
focal_class.signature: void writeStructure(OakStructure structure, Path outputPath)
focal_class.class_method_signature: StructureWriter.writeMMTFStructure(OakStructure structure, Path outputPath)
focal_class.full_signature: public static void writeMMTFStructure(OakStructure structure, Path outputPath)
focal_class.identifier: writeMMTFStructure
focal_class.modifiers: public static
focal_class.parameters: (OakStructure structure, Path outputPath)
focal_class.return: void
focal_class.signature: void writeMMTFStructure(OakStructure structure, Path outputPath)
focal_class.class_method_signature: StructureWriter.writeWithConsecutiveNumbering(OakStructure structure, Path outputPath)
focal_class.full_signature: public static void writeWithConsecutiveNumbering(OakStructure structure, Path outputPath)
focal_class.identifier: writeWithConsecutiveNumbering
focal_class.modifiers: public static
focal_class.parameters: (OakStructure structure, Path outputPath)
focal_class.return: void
focal_class.signature: void writeWithConsecutiveNumbering(OakStructure structure, Path outputPath)
focal_class.class_method_signature: StructureWriter.prepareForConsecutiveRewrite(OakStructure structure)
focal_class.full_signature: private static OakStructure prepareForConsecutiveRewrite(OakStructure structure)
focal_class.identifier: prepareForConsecutiveRewrite
focal_class.modifiers: private static
focal_class.parameters: (OakStructure structure)
focal_class.return: OakStructure
focal_class.signature: OakStructure prepareForConsecutiveRewrite(OakStructure structure)
focal_class.class_method_signature: StructureWriter.writeToXYZ(AtomContainer atomContainer, Path outputPath)
focal_class.full_signature: public static void writeToXYZ(AtomContainer atomContainer, Path outputPath)
focal_class.identifier: writeToXYZ
focal_class.modifiers: public static
focal_class.parameters: (AtomContainer atomContainer, Path outputPath)
focal_class.return: void
focal_class.signature: void writeToXYZ(AtomContainer atomContainer, Path outputPath)
focal_method.body: public static void writeMMTFStructure(OakStructure structure, Path outputPath) throws IOException {
          AdapterToStructureData structureAdapterInterface = new AdapterToStructureData();
          // init structure
          structureAdapterInterface.initStructure(0, structure.getAllAtoms().size(),
                  structure.getAllLeafSubstructures().size(),
                  structure.getAllChains().size(),
                  structure.getAllModels().size(),
                  structure.getPdbIdentifier().toLowerCase());
          structureAdapterInterface.setMmtfProducer("SiNGA");
  
          // TODO currently we do not consider header information
          // add header information
          structureAdapterInterface.setHeaderInfo(0.0F, 0.0F, 0.0F, structure.getTitle(), "yyyy/mm/dd", "yyyy/mm/dd", new String[]{"xtal"});
  
          // handle all models
          List<Model> allModels = structure.getAllModels();
          for (int i = 0; i < allModels.size(); i++) {
              Model model = allModels.get(i);
              List<Chain> allChains = model.getAllChains();
              structureAdapterInterface.setModelInfo(i, allChains.size());
              // handle all chains
              for (Chain chain : allChains) {
                  List<LeafSubstructure<?>> leafSubstructures = chain.getAllLeafSubstructures();
                  // TODO here we presumably need a mapping between "real" chain names and internal IDs as first argument
                  structureAdapterInterface.setChainInfo(chain.getChainIdentifier(), chain.getChainIdentifier(), leafSubstructures.size());
                  for (int j = 0; j < leafSubstructures.size(); j++) {
                      LeafSubstructure<?> leafSubstructure = leafSubstructures.get(j);
                      List<Atom> atoms = leafSubstructure.getAllAtoms();
                      char insertionCode = leafSubstructure.getInsertionCode();
                      if (insertionCode == '\u0000') {
                          insertionCode = MmtfStructure.UNAVAILABLE_CHAR_VALUE;
                      }
                      StructuralFamily family = leafSubstructure.getFamily();
                      char oneLetterCode = family.getOneLetterCode().charAt(0);
                      // TODO correct vocabulary has to be found for polymerType
                      // TODO sequenceIndex corresponds to SEQRES number which we do not consider for the moment
                      // TODO secStrucType is an integer and follows the DSSP numenclature, BioJava: DsspType
                      structureAdapterInterface.setGroupInfo(
                              leafSubstructure.getThreeLetterCode().toUpperCase(),
                              leafSubstructure.getSerial(),
                              insertionCode,
                              "L-peptide linking",
                              leafSubstructure.getAllAtoms().size(),
                              0,
                              oneLetterCode,
                              leafSubstructure.getSerial(),
                              leafSubstructure instanceof MmtfAminoAcid ? ((MmtfAminoAcid) leafSubstructure).getSecondaryStructure().getMmtfCode() : -1);
                      for (Atom atom : atoms) {
                          // TODO currently alternate location, occupancy, and B-factor are ignored
                          structureAdapterInterface.setAtomInfo(atom.getAtomName(), atom.getAtomIdentifier(), MmtfStructure.UNAVAILABLE_CHAR_VALUE,
                                  ((float) atom.getPosition().getX()), ((float) atom.getPosition().getY()), ((float) atom.getPosition().getZ()),
                                  1.0F, 0.0F, atom.getElement().getSymbol().toUpperCase(), atom.getElement().getCharge());
                          // TODO here we should add bonds
                          // addBonds(atom, atoms, allAtoms);
                      }
                  }
              }
          }
          structureAdapterInterface.finalizeStructure();
          Files.createDirectories(outputPath.getParent());
          WriterUtils.writeDataToFile(structureAdapterInterface, outputPath);
      }
focal_method.class_method_signature: StructureWriter.writeMMTFStructure(OakStructure structure, Path outputPath)
focal_method.full_signature: public static void writeMMTFStructure(OakStructure structure, Path outputPath)
focal_method.identifier: writeMMTFStructure
focal_method.invocations: initStructure size getAllAtoms size getAllLeafSubstructures size getAllChains size getAllModels toLowerCase getPdbIdentifier setMmtfProducer setHeaderInfo getTitle getAllModels size get getAllChains setModelInfo size getAllLeafSubstructures setChainInfo getChainIdentifier getChainIdentifier size size get getAllAtoms getInsertionCode getFamily charAt getOneLetterCode setGroupInfo toUpperCase getThreeLetterCode getSerial size getAllAtoms getSerial getMmtfCode getSecondaryStructure setAtomInfo getAtomName getAtomIdentifier getX getPosition getY getPosition getZ getPosition toUpperCase getSymbol getElement getCharge getElement finalizeStructure createDirectories getParent writeDataToFile
focal_method.modifiers: public static
focal_method.parameters: (OakStructure structure, Path outputPath)
focal_method.return: void
focal_method.signature: void writeMMTFStructure(OakStructure structure, Path outputPath)