Skip to content

Commit

Permalink
Regenerate test bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusklein committed Aug 31, 2024
1 parent 40c6dd5 commit d0f9467
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/chinese_hamster_hcd_selected_head.mzlb.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mzSpecLib 1.0>
<mzSpecLib>
MS:1003186|library format version=1.0
MS:1003188|library name=examples/chinese_hamster_hcd_selected_head
<AttributeSet Spectrum=all>
Expand Down
6 changes: 4 additions & 2 deletions mzspeclib/backends/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,10 @@ def flush(self):
json.dump(spectra, self.handle)

def close(self):
self.flush()
self.handle.close()
if not self.handle.closed:
self.flush()
self.handle.close()



def format_spectrum(spectrum: Spectrum, pretty_print=True, **kwargs) -> str:
Expand Down
3 changes: 2 additions & 1 deletion mzspeclib/backends/msp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2146,4 +2146,5 @@ def _write_peaks(self, spectrum: Spectrum):
self.handle.write(f'{peak[0]:0.4f}\t{peak[1]:0.4f}\t"{annot}"\n')

def close(self):
self.handle.close()
if not self.handle.closed:
self.handle.close()
3 changes: 2 additions & 1 deletion mzspeclib/backends/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,8 @@ def write_cluster(self, cluster: SpectrumCluster):
self.handle.write("\n")

def close(self):
self.handle.close()
if not self.handle.closed:
self.handle.close()


def format_aggregation(value: Union[numbers.Number, str]) -> str:
Expand Down
3 changes: 2 additions & 1 deletion mzspeclib/backends/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,9 @@ def close(self):
self.buffer.close()
return self.stream.close()

@property
def closed(self):
return self.stream.closed()
return self.stream.closed

def seekable(self):
return True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data/chinese_hamster_hcd_selected_head.mzlb.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mzSpecLib 1.0>
<mzSpecLib>
MS:1003186|library format version=1.0
MS:1003188|library name=tests/test_data/chinese_hamster_hcd_selected_head
<AttributeSet Spectrum=all>
Expand Down

0 comments on commit d0f9467

Please sign in to comment.