CellMigStandOrg / biotracks

A repository for data package representation for cell tracking data
https://pypi.python.org/pypi/biotracks
BSD 2-Clause "Simplified" License
12 stars 9 forks source link

Specify explicitly tracking software used for input #16

Open pcmasuzzo opened 7 years ago

pcmasuzzo commented 7 years ago

As for now, the library has one reader ([readfile.py](https://github.com/CellMigStandOrg/cell_track_dpkg/blob/master/dpkg/readfile.py)), which reads file input depending on tracking software used:

def read_file(f, track_dict):
    """Takes file from command line.
    Keyword arguments:
    f -- the file (from command line)
    track_dict -- only needed for some file formats!
    """
    # check for file extension
    if f.endswith('.xls'):
        # first thing, try to convert it to a plain csv
        try:
            xls_to_csv(f)
            name, extension = os.path.splitext(f)
            f = name + '.csv'
            print('XLS converted into csv...')
        except XLRDError:
            # copy the file and save it as csv
            import shutil
            name, extension = os.path.splitext(f)
            shutil.copyfile(f, name + '.csv')
            f = name + '.csv'
            print('Not an excel file.' + ' Copied and simply renamed to csv.')

    elif f.endswith('.xml'):
        # right now XML associated only to TrackMate, might not be the case in
        # the future
        (objects, links) = read_trackMate(f)
        print('Successfully parsed a TrackMate XML file...')

    if f.endswith('.csv'):

It would be much more clear and less error-prone to force the usage of a specific reader for each of the tracking software covered by the library.

simleo commented 7 years ago

We can add an option to force a specific format and fall back to some default for known file extensions (we do something similar in Bio-Formats).