Package jgromacs.io
Class IOData
- java.lang.Object
-
- jgromacs.io.IOData
-
public class IOData extends java.lang.Object
This class contains static methods for IO of data objects
-
-
Constructor Summary
Constructors Constructor Description IOData()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
howManyModelsInPDB(java.lang.String filename)
Returns the number of models in the given PDB filestatic Alignment
readAlignmentFromFASTA(java.lang.String filename)
Reads an alignment from the given FASTA filestatic Trajectory
readDumpedTrajectory(Structure structure, java.lang.String filename)
Reads a trajectory from the given dumped XTC or TRR filestatic 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 filestatic IndexSet
readIndexSetFromNDX(java.lang.String filename)
Reads an index set from the given NDX filestatic IndexSetList
readIndexSetListFromNDX(java.lang.String filename)
Reads an index set list from the given NDX filestatic Sequence
readSequenceFromFASTA(java.lang.String filename)
Reads a sequence from the given FASTA filestatic Structure
readStructureFromGRO(java.lang.String filename)
Reads structure from the given GRO filestatic Structure
readStructureFromPDB(java.lang.String filename)
Reads structure from the given PDB filestatic Structure
readStructureFromPDB(java.lang.String filename, int model)
Reads the given model from the given PDB filestatic Structure[]
readStructuresFromPDB(java.lang.String filename)
Reads an ensemble of structures from the given PDB filestatic Structure[]
readStructuresFromPDBsInDirectory(java.lang.String path)
Reads an ensemble of structures from PDB files in the given directorystatic Trajectory
readTrajectory(Structure structure, java.lang.String filename)
Reads a trajectory from the given XTC or TRR filestatic 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 filestatic void
writeIndexSetListToNDX(java.lang.String filename, IndexSetList indexsetlist)
Writes an index set list to the given NDX filestatic void
writeIndexSetToNDX(java.lang.String filename, IndexSet set)
Writes an index set to the given NDX filestatic void
writeSequenceToFASTA(java.lang.String filename, Sequence sequence)
Writes a sequence to the given FASTA filestatic void
writeStructureToGRO(java.lang.String filename, Structure structure)
Writes a structure to the given GRO filestatic void
writeStructureToPDB(java.lang.String filename, Structure structure)
Writes a structure to the given PDB file
-
-
-
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 namemodel
- 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 namestructure
- 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 namestructure
- 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 structurefilename
- 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 structurefilename
- 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 namesequence
- 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 namealignment
- 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 nameset
- 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 nameindexsetlist
- 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 executedfilenames
- 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
-
-