| 1 | #!/usr/bin/env perl | ||
| 2 | # | ||
| 3 | # Example script on how to use Convert::Pheno directly from Perl | ||
| 4 | # | ||
| 5 | # This file is part of Convert::Pheno | ||
| 6 | # | ||
| 7 | # Last Modified: Apr/15/2026 | ||
| 8 | # | ||
| 9 | # $VERSION taken from Convert::Pheno | ||
| 10 | # | ||
| 11 | # Copyright (C) 2022-2026 Manuel Rueda - CNAG (manuel.rueda@cnag.eu) | ||
| 12 | # | ||
| 13 | # License: Artistic License 2.0 | ||
| 14 | |||
| 15 | use strict; | ||
| 16 | use warnings; | ||
| 17 | use JSON::XS; | ||
| 18 | |||
| 19 | # Provide the path to <convert-pheno/lib> when running from the repository | ||
| 20 | # checkout instead of an installed Perl environment. | ||
| 21 | use lib '../../lib'; | ||
| 22 | use Convert::Pheno; | ||
| 23 | |||
| 24 | # Define method | ||
| 25 | my $method = 'pxf2bff'; | ||
| 26 | |||
| 27 | # Define data | ||
| 28 | my $my_pxf_json_data = { | ||
| 29 | "phenopacket" => { | ||
| 30 | "id" => "P0007500", | ||
| 31 | "subject" => { | ||
| 32 | "id" => "P0007500", | ||
| 33 | "dateOfBirth" => "2000-01-01T00:00:00Z", | ||
| 34 | "sex" => "FEMALE" | ||
| 35 | } | ||
| 36 | } | ||
| 37 | }; | ||
| 38 | |||
| 39 | # Create object. Module parameters are passed in one flat hash, unlike the | ||
| 40 | # structured HTTP(s) API payload. | ||
| 41 | my $convert = Convert::Pheno->new( | ||
| 42 | { | ||
| 43 | data => $my_pxf_json_data, | ||
| 44 | method => $method, | ||
| 45 | test => 1, | ||
| 46 | } | ||
| 47 | ); | ||
| 48 | |||
| 49 | # Run method and print formatted JSON | ||
| 50 | my $result = $convert->$method; | ||
| 51 | print JSON::XS->new->canonical->pretty->encode($result); |