8.5.5 How do I load a pedigree from a string?

There are some use cases for which it is desirable to load pedigrees from strings rather than from files. This is done by passing the pedsource keyword to pyp_newclasses.loadPedigree with a value of "textstream", along with a string named "pedstream" (Figure 8.1):
options = {}
options['pedfile'] = ''
options['renumber'] = 1
options['pedformat'] = 'ASD'
if __name__ == "__main__":
    pedstream = 'a1,s1,d1\na2,s2,d2\na3,a1,a2\n'
    test = pyp_newclasses.loadPedigree(options,pedsource='textstream',pedstream=pedstream)
    pyp_graphics.new_draw_pedigree(test, gfilename='partial', gtitle='Text Stream', gorient='p',gname=1)
Note that only ASD-formatted pedigrees can be loaded this way, individual IDs are separated with commas, and successive records are separated by newlines. All records must contain a newline, including the last record in the string! You must also set the "pedfile" option to a value, even if that value is just an empty string as in the example.
Figure 8.1: Pedigree loaded from a string
See About this document... for information on suggesting changes.