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, andColumn) is immutable to the user but maintains some internal state to improve performance. Therefore, multi-threaded access to data of oneCifFileis not safe and should be avoided.
-
-
Constructor Summary
Constructors Constructor Description CifIO()
-
Method Summary
All Methods Static Methods Concrete Methods 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.
-
-
-
Method Detail
-
readById
public static CifFile readById(String pdbId) throws IOException
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
public static CifFile readById(String pdbId, CifOptions options) throws IOException
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
public static CifFile readFromURL(URL url) throws IOException
- 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
public static CifFile readFromURL(URL url, CifOptions options) throws IOException
- 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
public static CifFile readFromPath(Path path) throws IOException
- 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
public static CifFile readFromPath(Path path, CifOptions options) throws IOException
- 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
public static CifFile readFromInputStream(InputStream inputStream) throws IOException
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 IOException
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 automaticallyoptions-CifOptionsfor the reading process- Returns:
- a
CifFileinstance - Throws:
IOException- thrown when reading fails
-
writeBinary
public static void writeBinary(CifFile cifFile, Path outputFile) throws IOException
- 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
public static byte[] writeBinary(CifFile cifFile) throws IOException
Convert aCifFileto its binarybyte[]representation.- Parameters:
cifFile- theCifFileto process- Returns:
- a
byte[]representing the information to write - Throws:
IOException- thrown when writing fails
-
writeBinary
public static byte[] writeBinary(CifFile cifFile, CifOptions options) throws IOException
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
public static void writeText(CifFile cifFile, Path outputFile) throws IOException
- 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
public static byte[] writeText(CifFile cifFile) throws IOException
Convert aCifFileto its textbyte[]representation.- Parameters:
cifFile- theCifFileto process- Returns:
- a
byte[]representing the information to write - Throws:
IOException- thrown when conversion fails
-
writeText
public static byte[] writeText(CifFile cifFile, CifOptions options) throws IOException
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
-
-