Skip to content

Commit e03feb5

Browse files
committed
Fix bugs
1 parent 6a2e044 commit e03feb5

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

dimspy/dimspy.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,13 @@ def main():
294294
#########################################
295295

296296
parser_gap.add_argument('-i', '--input',
297-
required=True, default=[], action='append',
297+
type=str, required=True,
298298
help="Single or Multiple HDF5 files that contain a peak matrix object from one of the processing steps.")
299299

300+
parser_gap.add_argument('-n', '--name-peaklist',
301+
required=True, type=str,
302+
help="HDF5 file to save the peaklist objects.")
303+
300304
parser_gap.add_argument('-o', '--output',
301305
required=True, type=str,
302306
help="HDF5 file to save the peaklist objects.")
@@ -412,25 +416,26 @@ def main():
412416
hdf5_portal.save_peak_matrix_as_hdf5(pm_sf, args.output)
413417

414418
elif args.step == "merge-peaklists":
415-
pls_merged = workflow.merge_peaklists(sources=args.input, filelist=args.filelist)
419+
pls_merged = workflow.merge_peaklists(source=args.input, filelist=args.filelist)
416420
hdf5_portal.save_peaklists_as_hdf5(pls_merged, args.output)
417421

418422
elif args.step == "get-peaklists":
419423
pls = []
420424
for s in args.input:
421-
if os.path.isfile(args.input):
422-
raise OSError('HDF5 database [%s] not exists'.format(args.input))
423-
if h5py.is_hdf5(args.input):
424-
raise OSError('input file [%s] is not a valid HDF5 database'.format(args.input))
425-
pls.extend(hdf5_portal.load_peak_matrix_from_hdf5(s).get_peaklists())
425+
if not os.path.isfile(s):
426+
raise OSError('HDF5 database [{}] not exists'.format(s))
427+
if not h5py.is_hdf5(s):
428+
raise OSError('input file [{}] is not a valid HDF5 database'.format(s))
429+
pm = hdf5_portal.load_peak_matrix_from_hdf5(s)
430+
pls.extend(pm.get_peaklists())
426431
hdf5_portal.save_peaklists_as_hdf5(pls, args.output)
427432

428433
elif args.step == "get-average-peaklist":
429-
if os.path.isfile(args.input):
430-
raise OSError('HDF5 database [%s] not exists'.format(args.input))
431-
if h5py.is_hdf5(args.input):
432-
raise OSError('input file [%s] is not a valid HDF5 database'.format(args.input))
433-
pls = [hdf5_portal.load_peak_matrix_from_hdf5(args.input).to_peaklist()]
434+
if not os.path.isfile(args.input):
435+
raise OSError('HDF5 database [{}] not exists'.format(args.input))
436+
if not h5py.is_hdf5(args.input):
437+
raise OSError('input file [{}] is not a valid HDF5 database'.format(args.input))
438+
pls = [hdf5_portal.load_peak_matrix_from_hdf5(args.input).to_peaklist(ID=args.name_peaklist)]
434439
hdf5_portal.save_peaklists_as_hdf5(pls, args.output)
435440

436441
elif args.step == "hdf5-to-txt":

dimspy/models/peak_matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ def get_peaklist(self, peaklist_id):
218218
pl.add_attribute(k, v[idx][nzero_idx])
219219
return pl
220220

221-
def get_peaklists(self, all_attr=True):
221+
def get_peaklists(self):
222222
# Recreate all peaklists used for the peak matrix
223-
return [self.get_peaklist(pid, all_attr) for pid in self.peaklist_ids]
223+
return [self.get_peaklist(pid) for pid in self.peaklist_ids]
224224

225225
def remove_samples(self, ids, remove_empty_peaks=True, masked_only=True):
226226
rmids = np.arange(self.full_shape[0])[self.mask][list(ids)] if masked_only else ids

0 commit comments

Comments
 (0)