1# Copyright 2001 by Katharine Lindner. All rights reserved. 2# Copyright 2006 by PeterC. All rights reserved. 3# This code is part of the Biopython distribution and governed by its 4# license. Please see the LICENSE file that should have been included 5# as part of this package. 6 7"""Hold GEO data in a straightforward format. 8 9classes:10o Record - All of the information in an GEO record.1112See http://www.ncbi.nlm.nih.gov/geo/13"""1415from__future__importprint_function1617

19"""Hold GEO information in a format similar to the original record.2021 The Record class is meant to make data easy to get to when you are22 just interested in looking at GEO data.2324 Attributes:25 entity_type26 entity_id27 entity_attributes28 col_defs29 table_rows3031 """

40output=''41output+='GEO Type: %s\n'%self.entity_type42output+='GEO Id: %s\n'%self.entity_id43att_keys=sorted(self.entity_attributes)44forkeyinatt_keys:45contents=self.entity_attributes[key]46ifisinstance(contents,list):47foritemincontents:48try:49output+='%s: %s\n'%(key,item[:40])50output+=out_block(item[40:])51except:52pass53elifisinstance(contents,str):54output+='%s: %s\n'%(key,contents[:40])55output+=out_block(contents[40:])56else:57print(contents)58output+='%s: %s\n'%(key,contents[:40])59output+=out_block(contents[40:])60col_keys=sorted(self.col_defs)61output+='Column Header Definitions\n'62forkeyincol_keys:63val=self.col_defs[key]64output+=' %s: %s\n'%(key,val[:40])65output+=out_block(val[40:],' ')66# May have to display VERY large tables,67# so only show the first 20 lines of data68MAX_ROWS=20+1# include header in count69forrowinself.table_rows[0:MAX_ROWS]:70output+='%s: '%self.table_rows.index(row)71forcolinrow:72output+='%s\t'%col73output+='\n'74iflen(self.table_rows)>MAX_ROWS:75output+='...\n'76row=self.table_rows[-1]77output+='%s: '%self.table_rows.index(row)78forcolinrow:79output+='%s\t'%col80output+='\n'8182returnoutput