You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Could not determine the type of the given file, make it .pdb.gz or .cif.gz",
90
-
Context::show(filename),
91
-
)])
92
-
}
93
-
}else{
94
-
Err(vec![PDBError::new(
95
-
ErrorLevel::BreakingError,
96
-
"Incorrect extension",
97
-
"Could not determine the type of the given file, make it .pdb.gz or .cif.gz",
98
-
Context::show(filename),
99
-
)])
100
-
}
101
-
}
102
-
103
-
/// Open a stream with either PDB or mmCIF data. The distinction is made on the start of the first line.
104
-
/// If it starts with `HEADER` it is a PDB file, if it starts with `data_` it is a mmCIF file.
105
-
///
106
-
/// # Errors
107
-
/// Returns a `PDBError` if a `BreakingError` is found. Otherwise it returns the PDB with all errors/warnings found while parsing it.
108
-
/// It returns a breaking error if the buffer could not be read, the file type could not be determined form the first line, or there was a breaking error in the file itself.
109
-
/// See the `PDBError` for more details.
110
-
///
111
-
/// # Related
112
-
/// If you want to open a file see [`open`]. There are also function to open a specified file type directly
113
-
/// see [`crate::open_pdb_raw`] and [`crate::open_mmcif_raw`] respectively.
114
-
pubfnopen_raw<T: std::io::Read + std::io::Seek>(
115
-
mutinput: std::io::BufReader<T>,
116
-
level:StrictnessLevel,
117
-
) -> ReadResult{
118
-
letmut first_line = String::new();
119
-
if input.read_line(&mut first_line).is_err(){
120
-
returnErr(vec![PDBError::new(
121
-
ErrorLevel::BreakingError,
122
-
"Buffer could not be read",
123
-
"The buffer provided to `open_raw` could not be read.",
124
-
Context::None,
125
-
)]);
126
-
}
127
-
if input.rewind().is_err(){
128
-
returnErr(vec![PDBError::new(
129
-
ErrorLevel::BreakingError,
130
-
"Buffer could not be read",
131
-
"The buffer provided to `open_raw` could not be rewound to the start.",
132
-
Context::None,
133
-
)]);
134
-
}
135
-
if first_line.starts_with("HEADER"){
136
-
open_pdb_raw(input,Context::None, level)
137
-
}elseif first_line.starts_with("data_"){
138
-
letmut contents = String::new();
139
-
if input.read_to_string(&mut contents).is_ok(){
140
-
open_mmcif_raw(&contents, level)
141
-
}else{
142
-
Err(vec![PDBError::new(
143
-
ErrorLevel::BreakingError,
144
-
"Buffer could not be read",
145
-
"The buffer provided to `open_raw` could not be read to end.",
146
-
Context::show(&first_line),
147
-
)])
148
-
}
149
-
}else{
150
-
Err(vec![PDBError::new(
151
-
ErrorLevel::BreakingError,
152
-
"Could not determine file type",
153
-
"Could not determine the type of the given file, make it .pdb or .cif",
0 commit comments