Mercurial > repos > melissacline > ucsc_cancer_utilities
diff seg2matrix/CGData/BaseTable.py @ 52:3a036a34c362
better handle of input file
author | jingchunzhu |
---|---|
date | Thu, 17 Sep 2015 15:00:45 -0700 |
parents | b6f5d2d1b047 |
children | b88b95642f59 |
line wrap: on
line diff
--- a/seg2matrix/CGData/BaseTable.py Thu Sep 17 14:33:21 2015 -0700 +++ b/seg2matrix/CGData/BaseTable.py Thu Sep 17 15:00:45 2015 -0700 @@ -63,24 +63,31 @@ linenum = 0 for row in read: linenum += 1 + if linenum ==1: #ignore header line + continue r = self.__row_class__() if (comment is None or not row[0].startswith(comment)) and not row[0].startswith("#"): for i, col in enumerate(cols): + skip =0 isOptional = False if 'columnDef' in self['cgformat'] and col in self['cgformat']['columnDef'] and 'optional' in self['cgformat']['columnDef'][col]: isOptional = self['cgformat']['columnDef'][col]['optional'] if len(row) > i: try: setattr(r, col, colType[col](row[i])) - except ValueError: + except ValueError: raise ValueError( "col invalid type %s on line %d" % (row[i], linenum)) else: if isOptional: setattr(r, col, None) else: print row + skip =1 # ignore bad lines + break raise InvalidFormat("missing colum " + col) - + if skip: + continue + if not self.groupKey: if self.secondKey is not None: key1 = getattr(r, self.firstKey )