run.py 2.28 KB
Newer Older
HERBERT Ryan's avatar
HERBERT Ryan committed
1
class Run(SampleSet):
HERBERT Ryan's avatar
HERBERT Ryan committed
2
3
    def __init__(self, type):
        super(Run, self).__init__(type)
HERBERT Ryan's avatar
HERBERT Ryan committed
4
5
6
7
8
9

    def get_fields(self):
        fields = super(Run, self).get_fields()
        fields.insert(1, {'name': 'run_date', 'sort': 'run_date', 'call': self.get_run_date, 'width': 100, 'public': True})
        return fields

10
11
12
13
14
    def get_reduced_fields(self):
        fields = super(Run, self).get_reduced_fields()
        fields.insert(1, {'name': 'run_date', 'sort': 'run_date', 'call': self.get_run_date, 'width': 100, 'public': True})
        return fields

HERBERT Ryan's avatar
HERBERT Ryan committed
15
    def get_name(self, data):
16
        return data['name']
HERBERT Ryan's avatar
HERBERT Ryan committed
17

18
19
20
    def get_display_name(self, data):
        return SPAN(self.get_name(data), _class="set_token run_token")

HERBERT Ryan's avatar
HERBERT Ryan committed
21
    def get_embellished_name(self, data):
22
        return 'run: %s' % data['name']
HERBERT Ryan's avatar
HERBERT Ryan committed
23

HERBERT Ryan's avatar
HERBERT Ryan committed
24
    def get_run_date(self, data):
25
        return "%s" % str(data['run_date']) if data['run_date'] is not None else ''
HERBERT Ryan's avatar
HERBERT Ryan committed
26
27

    def filter(self, filter_str, data):
28
29
        keys = ['name', 'confs', 'groups', 'run_date', 'info']
        self.create_filter_string(data, keys)
HERBERT Ryan's avatar
HERBERT Ryan committed
30
        return filter(lambda row : vidjil_utils.advanced_filter(row['string'], filter_str), data)
31
32

    def get_info_dict(self, data):
33
        return dict(name = self.get_display_name(data),
34
35
36
                    filename = "run : " + data['name'] + "_" + str(data['run_date']),
                    label = data['id_label'] + " (" + str(data['run_date']) + ")",
                    info = data['info']
37
38
39
40
                    )

    def get_data(self, sample_set_id):
        return db(db.run.sample_set_id == sample_set_id).select()[0]
41
42

    def get_id_string(self, data):
43
        name = data['name']
44
45
46
47
48
        ident = " (%d)" % data['sample_set_id']
        run_date = ""
        if data['run_date'] is not None:
            run_date = " (%s)" % data['run_date']
        return ":r %s%s%s" % (name, run_date, ident)
Ryan Herbert's avatar
Ryan Herbert committed
49
50
51
52
53
54
55
56
57
58
59

    def validate(self, data):
        error = []
        if data["name"] == "":
            error.append("name needed")

        if data["run_date"] != "":
            try:
                datetime.datetime.strptime(""+data['run_date'], '%Y-%m-%d')
            except ValueError:
                error.append("date (wrong format)")
Ryan Herbert's avatar
Ryan Herbert committed
60
        if data["name"].find("|") >= 0:
61
62
            error.append("illegal character '|' in name")

Ryan Herbert's avatar
Ryan Herbert committed
63
        return error