Package org.rcsb.cif
Class CifIO
java.lang.Object
org.rcsb.cif.CifIO
public class CifIO extends Object
Collection of IO operations to retrieve, process, and write CIF files. All read and write operations are thread-safe.
The data model (i.e.
CifFile, Block, Category, and
Column) is immutable to the user but maintains some internal state to improve performance.
Therefore, multi-threaded access to data of one CifFile is not safe and should be avoided.-
Constructor Summary
Constructors Constructor Description CifIO() -
Method Summary
Modifier and Type Method Description static CifFilereadById(String pdbId)Read aCifFilefrom web.static CifFilereadById(String pdbId, CifOptions options)Read aCifFilefrom web.static CifFilereadFromInputStream(InputStream inputStream)Read aCifFilefrom a givenInputStream.static CifFilereadFromInputStream(InputStream inputStream, CifOptions options)Read aCifFilefrom a givenInputStream.static CifFilereadFromPath(Path path)static CifFilereadFromPath(Path path, CifOptions options)static CifFilereadFromURL(URL url)static CifFilereadFromURL(URL url, CifOptions options)static byte[]writeBinary(CifFile cifFile)Convert aCifFileto its binarybyte[]representation.static voidwriteBinary(CifFile cifFile, Path outputFile)static voidwriteBinary(CifFile cifFile, Path outputFile, CifOptions options)static byte[]writeBinary(CifFile cifFile, CifOptions options)Convert aCifFileto its binarybyte[]representation.static byte[]writeText(CifFile cifFile)Convert aCifFileto its textbyte[]representation.static voidwriteText(CifFile cifFile, Path outputFile)static voidwriteText(CifFile cifFile, Path outputFile, CifOptions options)static byte[]writeText(CifFile cifFile, CifOptions options)Convert aCifFileto its textbyte[]representation.
-
Constructor Details
-
CifIO
public CifIO()
-
-
Method Details
-
readById
Read aCifFilefrom web. Refine the address viaCifOptions.CifOptionsBuilder.fetchUrl(String). Otherwise binaryCIF will be loaded.- Parameters:
pdbId- thepdbIdwhich should be fetched from the web - the library will determine whether the file is gzipped or plain information and whether it is in binary format (after resolving GZIP if needed) or text the appropriate reader will be chosen automatically- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
readById
Read aCifFilefrom web. Refine the address viaCifOptions.CifOptionsBuilder.fetchUrl(String). Otherwise binaryCIF will be loaded.- Parameters:
pdbId- thepdbIdwhich should be fetched from the web - the library will determine whether the file is gzipped or plain information and whether it is in binary format (after resolving GZIP if needed) or text the appropriate reader will be chosen automaticallyoptions-CifOptionsfor the reading process- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
readFromURL
- Parameters:
url- theURLfrom which to read - the library will determine whether the file is gzipped or plain information and whether it is in binary format (after resolving GZIP if needed) or text the appropriate reader will be chosen automatically- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
readFromURL
- Parameters:
url- theURLfrom which to read - the library will determine whether the file is gzipped or plain information and whether it is in binary format (after resolving GZIP if needed) or text the appropriate reader will be chosen automaticallyoptions-CifOptionsfor the reading process- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
readFromPath
- Parameters:
path- thePathfrom which to read - the library will determine whether the file is gzipped or plain information and whether it is in binary format (after resolving GZIP if needed) or text the appropriate reader will be chosen automatically- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
readFromPath
- Parameters:
path- thePathfrom which to read - the library will determine whether the file is gzipped or plain information and whether it is in binary format (after resolving GZIP if needed) or text the appropriate reader will be chosen automaticallyoptions-CifOptionsfor the reading process- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
readFromInputStream
Read aCifFilefrom a givenInputStream.- Parameters:
inputStream- theInputStreamto process - the library will determine whether the file is gzipped or plain information and whether it is in binary format (after resolving GZIP if needed) or text - the appropriate reader will be chosen automatically- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
readFromInputStream
public static CifFile readFromInputStream(InputStream inputStream, CifOptions options) throws IOExceptionRead aCifFilefrom a givenInputStream.- Parameters:
inputStream- theInputStreamto process - the library will determine whether the file is gzipped or plain information and whether it is in binary format (after resolving GZIP if needed) or text - the appropriate reader will be chosen automaticallyoptions-CifOptionsfor the reading process- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
writeBinary
- Parameters:
cifFile- theCifFileto processoutputFile- thePathwhere the content should be written- Throws:
IOException- thrown when writing fails
-
writeBinary
public static void writeBinary(CifFile cifFile, Path outputFile, CifOptions options) throws IOException- Parameters:
cifFile- theCifFileto processoutputFile- thePathwhere the content should be writtenoptions-CifOptionsfor the writing process- Throws:
IOException- thrown when writing fails
-
writeBinary
Convert aCifFileto its binarybyte[]representation.- Parameters:
cifFile- theCifFileto process- Returns:
- a
byte[]representing the information to write - Throws:
IOException- thrown when writing fails
-
writeBinary
Convert aCifFileto its binarybyte[]representation.- Parameters:
cifFile- theCifFileto processoptions-CifOptionsfor the writing process- Returns:
- a
byte[]representing the information to write - Throws:
IOException- thrown when writing fails
-
writeText
- Parameters:
cifFile- theCifFileto processoutputFile- thePathwhere the content should be written- Throws:
IOException- thrown when writing fails
-
writeText
public static void writeText(CifFile cifFile, Path outputFile, CifOptions options) throws IOException- Parameters:
cifFile- theCifFileto processoutputFile- thePathwhere the content should be writtenoptions-CifOptionsfor the writing process- Throws:
IOException- thrown when writing fails
-
writeText
Convert aCifFileto its textbyte[]representation.- Parameters:
cifFile- theCifFileto process- Returns:
- a
byte[]representing the information to write - Throws:
IOException- thrown when conversion fails
-
writeText
Convert aCifFileto its textbyte[]representation.- Parameters:
cifFile- theCifFileto processoptions-CifOptionsfor the writing process- Returns:
- a
byte[]representing the information to write - Throws:
IOException- thrown when conversion fails
-