Writes a list of molecules to an OutputStream.

@param   som  MoleculeSet that is written to an OutputStream
3363
public void writeAtomContainerSet(IAtomContainerSet som) {
        writeAtomContainer(som.getAtomContainer(0));
        for (int i = 1; i <= som.getAtomContainerCount() - 1; i++) {
            try {
                writeAtomContainer(som.getAtomContainer(i));
            } catch (Exception exc) {
            }
        }
    }
839489
public void writeMolecule(IAtomContainer mol) throws IOException {

        customizeJob();

        // write extra statements
        if (proccount.getSettingValue() > 1) {
            writer.write("%nprocl=" + proccount.getSettingValue());
            writer.write('\n');
        }
        if (!memory.getSetting().equals("unset")) {
            writer.write("%Mem=" + memory.getSetting());
            writer.write('\n');
        }
        if (usecheckpoint.isSet()) {
            if (mol.getID() != null && mol.getID().length() > 0) {
                writer.write("%chk=" + mol.getID() + ".chk");
            } else {
                // force different file names
                writer.write("%chk=" + System.currentTimeMillis() + ".chk");
            }
            writer.write('\n');
        }

        // write the command line
        writer.write("# " + method.getSetting() + "/" + basis.getSetting() + " ");
        String commandString = command.getSetting();
        if (commandString.equals("energy calculation")) {
            // ok, no special command needed
        } else if (commandString.equals("geometry optimization")) {
            writer.write("opt");
        } else if (commandString.equals("IR frequency calculation")) {
            writer.write("freq");
        } else if (commandString.equals("IR frequency calculation (with Raman)")) {
            writer.write("freq=noraman");
        } else {
            // assume that user knows what he's doing
            writer.write(commandString);
        }
        writer.write('\n');

        // next line is empty
        writer.write('\n');

        // next line is comment
        writer.write(comment.getSetting());
        writer.write('\n');

        // next line is empty
        writer.write('\n');

        /*
         * next line contains two digits the first is the total charge the
         * second is boolean indicating: 0 = open shell 1 = closed shell
         */
        writer.write("0 "); // FIXME: should write total charge of molecule
        if (shell.isSet()) {
            writer.write("0");
        } else {
            writer.write("1");
        }
        writer.write('\n');

        // then come all the atoms.
        // Loop through the atoms and write them out:
        Iterator<IAtom> atoms = mol.atoms().iterator();
        while (atoms.hasNext()) {
            IAtom a = atoms.next();
            String st = a.getSymbol();

            // export Eucledian coordinates (indicated by the 0)
            st = st + " 0 ";

            // export the 3D coordinates
            Point3d p3 = a.getPoint3d();
            if (p3 != null) {
                st = st + new Double(p3.x).toString() + " " + new Double(p3.y).toString() + " "
                        + new Double(p3.z).toString();
            }

            writer.write(st, 0, st.length());
            writer.write('\n');
        }

        // G98 expects an empty line at the end
        writer.write('\n');
    }
1355614
private synchronized void writeObject(java.io.ObjectOutputStream s)
        throws IOException
    {
        if (scope_ifname_set) {
            ifname = scope_ifname.getName();
        }
        s.defaultWriteObject();
    }
1263125
public static void writeProteinSequence(OutputStream outputStream,
			Collection<ProteinSequence> proteinSequences) throws Exception {

		GenbankWriter<ProteinSequence, AminoAcidCompound> genbankWriter = new GenbankWriter<ProteinSequence, AminoAcidCompound>(
				outputStream,
				proteinSequences,
				new GenericGenbankHeaderFormat<ProteinSequence, AminoAcidCompound>());
		genbankWriter.process();

	}
1233116
public static void writeProteinSequence(OutputStream outputStream,
			Collection<ProteinSequence> proteinSequences) throws Exception {

		FastaWriter<ProteinSequence, AminoAcidCompound> fastaWriter = new FastaWriter<ProteinSequence, AminoAcidCompound>(
				outputStream, proteinSequences,
				new GenericFastaHeaderFormat<ProteinSequence, AminoAcidCompound>());
		fastaWriter.process();

	}
406653
public static void writeAtomically(File file, byte[] bytes) throws IOException {
		AtomicFile atomicFile = new AtomicFile(file);
		FileOutputStream stream = null;
		try {
			stream = atomicFile.startWrite();
			stream.write(bytes);
			atomicFile.finishWrite(stream); // serialization was successful
		} catch (Exception e) {
			atomicFile.failWrite(stream); // serialization failed
			throw new IOException(e); // throw exception up the chain
		}
	}
837152
def write_file(self, molecule, inpfile):
        

        mol_blocks = []
        atom_block = AdfKey("Atoms", options=["cartesian"])
        for site in molecule:
            atom_block.add_subkey(AdfKey(str(site.specie), list(site.coords)))
        mol_blocks.append(atom_block)

        if molecule.charge != 0:
            netq = molecule.charge
            ab = molecule.spin_multiplicity - 1
            charge_block = AdfKey("Charge", [netq, ab])
            mol_blocks.append(charge_block)
            if ab != 0:
                unres_block = AdfKey("Unrestricted")
                mol_blocks.append(unres_block)

        with open(inpfile, "w+") as f:
            for block in mol_blocks:
                f.write(str(block) + "\n")
            f.write(str(self.task) + "\n")
            f.write("END INPUT")
633171
private void writeObject(final ObjectOutputStream out)
		throws IOException
	{
		out.defaultWriteObject();

		out.writeInt(_length);
		out.writeDouble(_p);
		out.writeInt(_genes.length);
		out.write(_genes);
	}
1372505
def write_nwchem(basis):
    '''
    '''

    # Uncontract all but SP
    basis = manip.uncontract_spdf(basis, 1, True)
    basis = sort.sort_basis(basis, True)

    s = ''

    # Elements for which we have electron basis
    electron_elements = [k for k, v in basis['elements'].items() if 'electron_shells' in v]

    # Elements for which we have ECP
    ecp_elements = [k for k, v in basis['elements'].items() if 'ecp_potentials' in v]

    if len(electron_elements) > 0:
        # basis set starts with a string
        s += 'BASIS "ao basis" PRINT\n'

        # Electron Basis
        for z in electron_elements:
            data = basis['elements'][z]
            sym = lut.element_sym_from_Z(z, True)
            s += '#BASIS SET: {}\n'.format(misc.contraction_string(data))

            for shell in data['electron_shells']:
                exponents = shell['exponents']
                coefficients = shell['coefficients']
                ncol = len(coefficients) + 1

                am = shell['angular_momentum']
                amchar = lut.amint_to_char(am).upper()
                s += '{}    {}\n'.format(sym, amchar)

                point_places = [8 * i + 15 * (i - 1) for i in range(1, ncol + 1)]
                s += printing.write_matrix([exponents, *coefficients], point_places)

        s += 'END\n'

    # Write out ECP
    if len(ecp_elements) > 0:
        s += '\n\nECP\n'

        for z in ecp_elements:
            data = basis['elements'][z]
            sym = lut.element_sym_from_Z(z, True)
            max_ecp_am = max([x['angular_momentum'][0] for x in data['ecp_potentials']])

            # Sort lowest->highest, then put the highest at the beginning
            ecp_list = sorted(data['ecp_potentials'], key=lambda x: x['angular_momentum'])
            ecp_list.insert(0, ecp_list.pop())

            s += '{} nelec {}\n'.format(sym, data['ecp_electrons'])

            for pot in ecp_list:
                rexponents = pot['r_exponents']
                gexponents = pot['gaussian_exponents']
                coefficients = pot['coefficients']

                am = pot['angular_momentum']
                amchar = lut.amint_to_char(am).upper()

                if am[0] == max_ecp_am:
                    s += '{} ul\n'.format(sym)
                else:
                    s += '{} {}\n'.format(sym, amchar)

                point_places = [0, 10, 33]
                s += printing.write_matrix([rexponents, gexponents, *coefficients], point_places)

        s += 'END\n'

    return s
617918
public static void writeNucleotideSequence(File file, Collection<DNASequence> dnaSequences) throws Exception {
		FileOutputStream outputStream = new FileOutputStream(file);
		BufferedOutputStream bo = new BufferedOutputStream(outputStream);
		writeNucleotideSequence(bo, dnaSequences);
		bo.close();
		outputStream.close();
	}
1255069
private IAtomContainerSet readAtomContainerSet(IAtomContainerSet som) {
        try {
            String line = input.readLine().trim();
            while (line != null) {
                logger.debug("Line: ", line);

                final String name = suffix(line);

                try {
                    IAtomContainer molecule = sp.parseSmiles(line);
                    molecule.setProperty("SMIdbNAME", name);
                    som.addAtomContainer(molecule);
                } catch (CDKException exception) {
                    logger.warn("This SMILES could not be parsed: ", line);
                    logger.warn("Because of: ", exception.getMessage());
                    logger.debug(exception);
                    IAtomContainer empty = som.getBuilder().newInstance(IAtomContainer.class, 0, 0, 0, 0);
                    empty.setProperty(IteratingSMILESReader.BAD_SMILES_INPUT, line);
                    som.addAtomContainer(empty);
                }
                if (input.ready()) {
                    line = input.readLine();
                } else {
                    line = null;
                }
            }
        } catch (Exception exception) {
            logger.error("Error while reading SMILES line: ", exception.getMessage());
            logger.debug(exception);
        }
        return som;
    }
929183
private void writeObject(final ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
        out.writeInt(table.length);

        // Have to use null-terminated list because size might shrink
        // during iteration

        for (final Object o : entrySet()) {
            final Map.Entry entry = (Map.Entry) o;
            out.writeObject(entry.getKey());
            out.writeObject(entry.getValue());
        }
        out.writeObject(null);
    }
1152055
public static void writeList(Collection<?> lines,
                                 OutputStream output) throws IOException {
        writeList(lines, output, Charset.defaultCharset());
    }
656372
private void writeObject(final ObjectOutputStream out)
		throws IOException
	{
		out.defaultWriteObject();

		out.writeInt(length());
		out.writeObject(_operations);
		out.writeObject(_terminals);

		for (ProgramGene<A> gene : _genes) {
			out.writeObject(gene.getAllele());
			out.writeInt(gene.childOffset());
		}
	}
197822
private void writeObject(java.io.ObjectOutputStream s)
                    throws java.io.IOException {

        s.defaultWriteObject();

        Object[] elements = getArray();
        // Write out array length
        s.writeInt(elements.length);

        // Write out all elements in the proper order.
        for (Object element : elements)
            s.writeObject(element);
    }
979238
@Override
    public void writeData(String tableName, EntityMetadata m, Object entity, Object rowId,
            List<RelationHolder> relations, boolean showQuery) throws IOException
    {
        HBaseRow hbaseRow = createHbaseRow(m, entity, rowId, relations);
        writeHbaseRowInATable(tableName, hbaseRow);
    }
71357
public static void writeProteinSequence(File file,
			Collection<ProteinSequence> proteinSequences) throws Exception {
		FileOutputStream outputStream = new FileOutputStream(file);
		BufferedOutputStream bo = new BufferedOutputStream(outputStream);
		writeProteinSequence(bo, proteinSequences);
		bo.close();
		outputStream.close();
	}