jgromacs.io
Class IOData

java.lang.Object
  extended by jgromacs.io.IOData

public class IOData
extends java.lang.Object

This class contains static methods for IO of data objects


Constructor Summary
IOData()
           
 
Method Summary
static int howManyModelsInPDB(java.lang.String filename)
          Returns the number of models in the given PDB file
static Alignment readAlignmentFromFASTA(java.lang.String filename)
          Reads an alignment from the given FASTA file
static Trajectory readDumpedTrajectory(Structure structure, java.lang.String filename)
          Reads a trajectory from the given dumped XTC or TRR file
static java.lang.Object readFromFile(java.lang.String filename)
          Reads a JGromacs object (Structure, IndexSetList, Trajectory or Sequence) from a file automatically identifying the type of the file
static IndexSet readIndexSetFromNDX(java.lang.String filename)
          Reads an index set from the given NDX file
static IndexSetList readIndexSetListFromNDX(java.lang.String filename)
          Reads an index set list from the given NDX file
static Sequence readSequenceFromFASTA(java.lang.String filename)
          Reads a sequence from the given FASTA file
static Structure readStructureFromGRO(java.lang.String filename)
          Reads structure from the given GRO file
static Structure readStructureFromPDB(java.lang.String filename)
          Reads structure from the given PDB file
static Structure readStructureFromPDB(java.lang.String filename, int model)
          Reads the given model from the given PDB file
static Structure[] readStructuresFromPDB(java.lang.String filename)
          Reads an ensemble of structures from the given PDB file
static Structure[] readStructuresFromPDBsInDirectory(java.lang.String path)
          Reads an ensemble of structures from PDB files in the given directory
static Trajectory readTrajectory(Structure structure, java.lang.String filename)
          Reads a trajectory from the given XTC or TRR file
static java.lang.Object[] runGromacsCommand(java.lang.String command, java.lang.String[] filenames)
          Executes Gromacs commands from within the Java code and reads the listed output files back into JGromacs objects.
static void writeAlignmentToFASTA(java.lang.String filename, Alignment alignment)
          Writes an alignment to the given FASTA file
static void writeIndexSetListToNDX(java.lang.String filename, IndexSetList indexsetlist)
          Writes an index set list to the given NDX file
static void writeIndexSetToNDX(java.lang.String filename, IndexSet set)
          Writes an index set to the given NDX file
static void writeSequenceToFASTA(java.lang.String filename, Sequence sequence)
          Writes a sequence to the given FASTA file
static void writeStructureToGRO(java.lang.String filename, Structure structure)
          Writes a structure to the given GRO file
static void writeStructureToPDB(java.lang.String filename, Structure structure)
          Writes a structure to the given PDB file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOData

public IOData()
Method Detail

readStructureFromGRO

public static Structure readStructureFromGRO(java.lang.String filename)
                                      throws java.io.IOException
Reads structure from the given GRO file

Parameters:
filename - Input file name
Returns:
structure as a Structure object
Throws:
java.io.IOException

readStructureFromPDB

public static Structure readStructureFromPDB(java.lang.String filename)
                                      throws java.io.IOException
Reads structure from the given PDB file

Parameters:
filename - Input file name
Returns:
structure as a Structure object
Throws:
java.io.IOException

readStructureFromPDB

public static Structure readStructureFromPDB(java.lang.String filename,
                                             int model)
                                      throws java.io.IOException
Reads the given model from the given PDB file

Parameters:
filename - Input file name
model - model to be read
Returns:
structure as a Structure object
Throws:
java.io.IOException

howManyModelsInPDB

public static int howManyModelsInPDB(java.lang.String filename)
                              throws java.io.IOException
Returns the number of models in the given PDB file

Parameters:
filename - Input file name
Returns:
number of models
Throws:
java.io.IOException

readStructuresFromPDB

public static Structure[] readStructuresFromPDB(java.lang.String filename)
                                         throws java.io.IOException
Reads an ensemble of structures from the given PDB file

Parameters:
filename - Input file name
Returns:
ensemble of structures as a Structure[] object
Throws:
java.io.IOException

readStructuresFromPDBsInDirectory

public static Structure[] readStructuresFromPDBsInDirectory(java.lang.String path)
                                                     throws java.io.IOException
Reads an ensemble of structures from PDB files in the given directory

Parameters:
path - path of directory
Returns:
ensemble of structures as a Structure[] object
Throws:
java.io.IOException

writeStructureToGRO

public static void writeStructureToGRO(java.lang.String filename,
                                       Structure structure)
                                throws java.io.IOException
Writes a structure to the given GRO file

Parameters:
filename - Output file name
structure - Structure object to be written out
Throws:
java.io.IOException

writeStructureToPDB

public static void writeStructureToPDB(java.lang.String filename,
                                       Structure structure)
                                throws java.io.IOException
Writes a structure to the given PDB file

Parameters:
filename - Output file name
structure - Structure object to be written out
Throws:
java.io.IOException

readTrajectory

public static Trajectory readTrajectory(Structure structure,
                                        java.lang.String filename)
                                 throws java.io.IOException
Reads a trajectory from the given XTC or TRR file

Parameters:
structure - reference structure
filename - Input file name
Returns:
trajectory as a Trajectory object
Throws:
java.io.IOException

readDumpedTrajectory

public static Trajectory readDumpedTrajectory(Structure structure,
                                              java.lang.String filename)
                                       throws java.io.IOException
Reads a trajectory from the given dumped XTC or TRR file

Parameters:
structure - reference structure
filename - Input file name
Returns:
trajectory as a Trajectory object
Throws:
java.io.IOException

readSequenceFromFASTA

public static Sequence readSequenceFromFASTA(java.lang.String filename)
                                      throws java.io.IOException
Reads a sequence from the given FASTA file

Parameters:
filename - Input file name
Returns:
sequence as a Sequence object
Throws:
java.io.IOException

readAlignmentFromFASTA

public static Alignment readAlignmentFromFASTA(java.lang.String filename)
                                        throws java.io.IOException
Reads an alignment from the given FASTA file

Parameters:
filename - Input file name
Returns:
alignment as an Alignment object
Throws:
java.io.IOException

writeSequenceToFASTA

public static void writeSequenceToFASTA(java.lang.String filename,
                                        Sequence sequence)
                                 throws java.io.IOException
Writes a sequence to the given FASTA file

Parameters:
filename - Output file name
sequence - Sequence object to be written out
Throws:
java.io.IOException

writeAlignmentToFASTA

public static void writeAlignmentToFASTA(java.lang.String filename,
                                         Alignment alignment)
                                  throws java.io.IOException
Writes an alignment to the given FASTA file

Parameters:
filename - Output file name
alignment - Alignment object to be written out
Throws:
java.io.IOException

readIndexSetFromNDX

public static IndexSet readIndexSetFromNDX(java.lang.String filename)
                                    throws java.io.IOException
Reads an index set from the given NDX file

Parameters:
filename - Input file name
Returns:
index set as an IndexSet object
Throws:
java.io.IOException

readIndexSetListFromNDX

public static IndexSetList readIndexSetListFromNDX(java.lang.String filename)
                                            throws java.io.IOException
Reads an index set list from the given NDX file

Parameters:
filename - Input file name
Returns:
index set list as an IndexSetList object
Throws:
java.io.IOException

writeIndexSetToNDX

public static void writeIndexSetToNDX(java.lang.String filename,
                                      IndexSet set)
                               throws java.io.IOException
Writes an index set to the given NDX file

Parameters:
filename - Output file name
set - IndexSet object to be written out
Throws:
java.io.IOException

writeIndexSetListToNDX

public static void writeIndexSetListToNDX(java.lang.String filename,
                                          IndexSetList indexsetlist)
                                   throws java.io.IOException
Writes an index set list to the given NDX file

Parameters:
filename - Output file name
indexsetlist - IndexSetList object to be written out
Throws:
java.io.IOException

runGromacsCommand

public static java.lang.Object[] runGromacsCommand(java.lang.String command,
                                                   java.lang.String[] filenames)
                                            throws java.io.IOException
Executes Gromacs commands from within the Java code and reads the listed output files back into JGromacs objects. (Note that the method can be used to execute not only Gromacs commands.) The commands are run in the Unix shell (sh), so for example shell pipes (>,>>,<,|) can also be used in the command line. The first element of the returned array is the standard output and next elements are the JGromacs objects read in.

Parameters:
command - Gromacs command to be executed
filenames - array of output file names to be read in
Returns:
array of JGromacs objects read from the files
Throws:
java.io.IOException

readFromFile

public static java.lang.Object readFromFile(java.lang.String filename)
                                     throws java.io.IOException
Reads a JGromacs object (Structure, IndexSetList, Trajectory or Sequence) from a file automatically identifying the type of the file

Parameters:
filename - Input file name with correct extension
Returns:
JGromacs object
Throws:
java.io.IOException