moonso / ped_parser

A python tool for parsing pedigree files
MIT License
16 stars 3 forks source link

Build/create PED files #5

Open robinandeer opened 9 years ago

robinandeer commented 9 years ago

Is it possible to use the package to create pedigree files from scratch?

When I try to create Individual objects and call e.g. get_json it only includes mandatory information and skips stuff in extra_info. I would like for this information to also be serialized - is this supported?

moonso commented 9 years ago

Hi,

this should work, i will look into it. Can you post the whole codeblock so I can see how you do it?

robinandeer commented 9 years ago

I should always script in iPython Notebook... Well, well:

>>> from ped_parser import Individual
>>> individual = Individual('ADM995A1', family='112', mother='ADM995A2', father='ADM995A3', sex='1', phenotype='2')
>>> individual.extra_info['Capture_kit'] = 'Agilent_SureSelect.V5'
>>> individual.get_json()
{u'family_id': '112',
 u'father': 'ADM995A3',
 u'id': 'ADM995A1',
 u'mother': 'ADM995A2',
 u'phenotype': '2',
 u'sex': '1'}
moonso commented 9 years ago

Would you like to have to_ped in the Individual class? Or are you gonna make a ped file from the json info?

robinandeer commented 9 years ago

I would probably create the Individual objects, then add them to a Family and lastly call .to_ped on the Family class. That way I also get the header row, right?

moonso commented 9 years ago

Yes but i'm thinking about making it possible on all levels, don't really know what is most reasonable

robinandeer commented 9 years ago

To me serializing to JSON would be nice on all levels. But serializing to PED on individual level is less interesting. Perhaps just make it a private method that is called by Family?

robinandeer commented 9 years ago

Following up: When I call to_ped() I don't get the "extra_info" columns as is the case in the JSON serialization. Any plans to include them in the output written in the PED format?