ClarID-Tools

 view release on metacpan or  search on metacpan

t/code.t  view on Meta::CPAN

            'species: Human',
            'subject_id: 1',
            'tissue: Liver',
            'sample_type: Tumor',
            'assay: RNA_seq',
            'condition: I25.110;C22.0',
            'timepoint: Baseline',
            'duration: P0D',
            'batch: ',
            'replicate: ',
        ],
        'biosample human decode (no batch no replicate default codebook path)'
    );
}   


# 16. Biosample human encode w/ multiple ICD (default codebook path)
{
    my $cmd =
"$^X $inc $exe code --project TCGA-AML --entity biosample --format human --action encode "
      . "--species Human --subject_id 1 --tissue Liver --sample_type Tumor "
      . "--assay RNA_seq --condition I25.110,C22.0 --timepoint Baseline --duration P0D --batch 1 --replicate 5";
    my $out = `$cmd`;
    chomp $out;
    is(     
        $out,
        'TCGA_AML-HomSap-00001-LIV-TUM-RNA-I25.110+C22.0-BSL-P0D-B01-R05',
        'biosample human encode w/ multiple ICD (default codebook path)'
    );
}

# 17. Subject human encode w/ multiple ICD
{
    my $cmd =
"$^X $inc $exe code --entity subject --format human --action encode --codebook $codebook "
      . "--study TestCohort --type Case --sex Male --age_group Age20to29 --subject_id 7 --condition I25.110,C22.0";
    my $out = `$cmd`;
    chomp $out;
    is(
        $out,
        'TestCohort-00007-Case-I25.110+C22.0-Male-A20_29',
        'subject human encode w/ multiple ICD'
    );
}

# 18. Subject human decode w/ multiple ICD
{
    my $cmd =
"$^X $inc $exe code --entity subject --format human --action decode --codebook $codebook "
      . "--clar_id TestCohort-00007-Case-I25.110+C22.0-Male-A20_29 --with-condition-name";

    my @got = map { chomp; $_ } `$cmd`;

    my $want = <<'EOF';
study: TestCohort
subject_id: 7
type: Case
condition: I25.110+C22.0
sex: Male
age_group: Age20to29
condition_name: Atherosclerotic heart disease of native coronary artery with unstable angina pectoris;Liver cell carcinoma
EOF
    chomp( my @want = split /\n/, $want );

    is_deeply \@got, \@want, 'subject human decode w/ multiple ICD with-condition-name';
}   

# 19. Subject human encode w/ multiple ICD
{
    my $cmd =
"$^X $inc $exe code --entity subject --format stub --action encode --codebook $codebook "
      . "--study TestCohort --type Case --sex Male --age_group Age20to29 --subject_id 7 --condition I25.110,C22.0";
    my $out = `$cmd`;
    chomp $out;

    is(
        $out,
        'TestCohort007C2to0N402MA2',
        'subject stub encode w/ multiple ICD'
    );
}

# 20. Subject human decode w/ multiple ICD
{
    my $cmd =
"$^X $inc $exe code --entity subject --format stub --action decode --codebook $codebook "
      . "--stub_id TestCohort007C2to0N402MA2 --with-condition-name";

    my @got = map { chomp; $_ } `$cmd`;

    my $want = <<'EOF';
study: TestCohort
subject_id: 7
type: Case
condition: I25.110;C22.0
sex: Male
age_group: Age20to29
condition_name: Atherosclerotic heart disease of native coronary artery with unstable angina pectoris;Liver cell carcinoma
EOF
    chomp( my @want = split /\n/, $want );

    is_deeply \@got, \@want, 'subject stub decode w/ multiple ICD with-condition-name';
}

# 21. Biosample human encode with duration=P0N
{
    my $cmd =
"$^X $inc $exe code --project TCGA-AML --entity biosample --format human --action encode --codebook $codebook "
  . "--species Human --subject_id 1 --tissue Liver --sample_type Tumor "
  . "--assay RNA_seq --condition I25.110 --timepoint Baseline --duration P0N --batch 1 --replicate 5";
    my $out = `$cmd`; chomp $out;
    is(
        $out,
        'TCGA_AML-HomSap-00001-LIV-TUM-RNA-I25.110-BSL-P0N-B01-R05',
        'biosample human encode duration=P0N'
    );
}

# 22. Biosample human decode with P0N
{
    my $cmd =
"$^X $inc $exe code --entity biosample --format human --action decode --codebook $codebook "
  . "--clar_id TCGA_AML-HomSap-00001-LIV-TUM-RNA-I25.110-BSL-P0N-B01-R05";
    my $out = `$cmd`; chomp $out;
    my @lines = split /\n/, $out;
    is_deeply \@lines, [
        'project: TCGA-AML',
        'species: Human',
        'subject_id: 1',
        'tissue: Liver',
        'sample_type: Tumor',
        'assay: RNA_seq',
        'condition: I25.110',
        'timepoint: Baseline',
        'duration: P0N',
        'batch: 1',
        'replicate: 5',
    ], 'biosample human decode duration=P0N';
}

# 23. Biosample stub encode with duration=P0N -> stub ends in 0N
{
    my $cmd =
"$^X $inc $exe code --project TCGA-AML --entity biosample --format stub --action encode --codebook $codebook "
  . "--species Human --subject_id 1 --tissue Liver --sample_type Tumor "
  . "--assay RNA_seq --condition I25.110 --timepoint Challenge --duration P0N --batch 1 --replicate 5";
    my $out = `$cmd`; chomp $out;
    is( $out, 'AML01001LTR2to01C0NB01R05', 'biosample stub encode duration=P0N -> 0N' );
}

# 24. Biosample stub decode with 0N -> P0N
{
    my $cmd =
"$^X $inc $exe code --entity biosample --format stub --action decode --codebook $codebook "
  . "--clar_id AML01001LTR2to01C0NB01R05 --subject_id_base62_width 3";
    my $out = `$cmd`; chomp $out;
    my @lines = split /\n/, $out;
    is_deeply \@lines, [



( run in 2.213 seconds using v1.01-cache-2.11-cpan-df04353d9ac )