001package org.biojava.nbio.structure.io; 002 003import org.biojava.nbio.structure.Structure; 004import org.biojava.nbio.structure.align.util.UserConfiguration; 005import org.biojava.nbio.structure.io.cif.CifStructureConverter; 006 007import java.io.IOException; 008import java.io.InputStream; 009 010/** 011 * Parse binary Cif files and provide capabilities to store them locally. 012 * @author Sebastian Bittrich 013 * @since 5.3.0 014 */ 015public class BcifFileReader extends LocalPDBDirectory { 016 public static final String[] CIF_SPLIT_DIR = new String[] { "data", "structures", "divided", "bcif" }; 017 public static final String[] CIF_OBSOLETE_DIR = new String[] { "data", "structures", "obsolete", "bcif" }; 018 019 /** 020 * Constructs a new BcifFileReader, initializing the extensions member variable. 021 * The path is initialized in the same way as {@link UserConfiguration}, 022 * i.e. to system property/environment variable {@link UserConfiguration#PDB_DIR}. 023 * Both autoFetch and splitDir are initialized to false 024 */ 025 public BcifFileReader() { 026 this(null); 027 } 028 029 /** 030 * Constructs a new BcifFileReader, initializing the extensions member variable. 031 * The path is initialized to the given path, both autoFetch and splitDir are initialized to false. 032 */ 033 public BcifFileReader(String path) { 034 super(path); 035 addExtension(".bcif"); 036 addExtension(".bcif.gz"); 037 } 038 039 @Override 040 public Structure getStructure(InputStream inStream) throws IOException { 041 return CifStructureConverter.fromInputStream(inStream, getFileParsingParameters()); 042 } 043 044 @Override 045 protected String getFilename(String pdbId) { 046 return pdbId.toLowerCase() + ".bcif"; 047 } 048 049 @Override 050 protected String[] getSplitDirPath() { 051 return CIF_SPLIT_DIR; 052 } 053 054 @Override 055 protected String[] getObsoleteDirPath() { 056 return CIF_OBSOLETE_DIR; 057 } 058}