Bio-KBase
view release on metacpan or search on metacpan
er_scripts/get_relationship_IsTerminusFor view on Meta::CPAN
#
# This is a SAS Component
#
=head1 get_relationship_IsTerminusFor
A terminus for a scenario is a compound that acts as its
input or output. A compound can be the terminus for many scenarios,
and a scenario will have many termini. The relationship attributes
indicate whether the compound is an input to the scenario or an
output. In some cases, there may be multiple alternative output
groups. This is also indicated by the attributes.
Example:
get_relationship_IsTerminusFor -a < ids > table.with.fields.added
would read in a file of ids and add a column for each field in the relationship.
The standard input should be a tab-separated table (i.e., each line
is a tab-separated set of fields). Normally, the last field in each
line would contain the id. If some other column contains the id,
use
-c N
where N is the column (from 1) that contains the id.
This is a pipe command. The input is taken from the standard input, and the
output is to the standard output.
=head2 Command-Line Options
=over 4
=item -c Column
This is used only if the column containing id is not the last.
=item -from field-list
Choose a set of fields from the Compound entity to return. Field-list is a comma-separated list of
strings. The following fields are available:
=over 4
=item id
=item label
=item abbr
=item msid
=item ubiquitous
=item mod_date
=item uncharged_formula
=item formula
=item mass
=back
=item -rel field-list
Choose a set of fields from the relationship to return. Field-list is a comma-separated list of
strings. The following fields are available:
=over 4
=item from_link
=item to_link
=item group_number
=back
=item -to field-list
Choose a set of fields from the Scenario entity to return. Field-list is a comma-separated list of
strings. The following fields are available:
=over 4
=item id
=item common_name
=back
=back
=head2 Output Format
The standard output is a tab-delimited file. It consists of the input
file with an extra column added for each requested field. Input lines that cannot
be extended are written to stderr.
=cut
use Bio::KBase::Utilities::ScriptThing;
use Bio::KBase::CDMI::CDMIClient;
use Getopt::Long;
#Default fields
my @all_from_fields = ( 'id', 'label', 'abbr', 'msid', 'ubiquitous', 'mod_date', 'uncharged_formula', 'formula', 'mass' );
my @all_rel_fields = ( 'from_link', 'to_link', 'group_number' );
my @all_to_fields = ( 'id', 'common_name' );
my %all_from_fields = map { $_ => 1 } @all_from_fields;
my %all_rel_fields = map { $_ => 1 } @all_rel_fields;
my %all_to_fields = map { $_ => 1 } @all_to_fields;
my @default_fields = ('from-link', 'to-link');
my @from_fields;
my @rel_fields;
my @to_fields;
my $usage = "usage: get_relationship_IsTerminusFor [-c column] [-a | -from field list -rel field list -to field list] < ids > extended.by.a.column(s)\n";
my $column;
my $input_file;
my $a;
my $f;
my $r;
my $t;
my $h;
my $i = "-";
my $geO = Bio::KBase::CDMI::CDMIClient->new_get_entity_for_script("c=i" => \$column,
"h" => \$h,
"show-fields" => \$h,
"a" => \$a,
"from=s" => \$f,
"rel=s" => \$r,
"to=s" => \$t,
'i=s' => \$i);
if ($h) {
print STDERR "from: ", join(",", @all_from_fields), "\n";
print STDERR "relation: ", join(",", @all_rel_fields), "\n";
print STDERR "to: ", join(",", @all_to_fields), "\n";
exit 0;
}
if ($a && ($f || $r || $t)) {die $usage};
if ($a) {
@from_fields = @all_from_fields;
@rel_fields = @all_rel_fields;
@to_fields = @all_to_fields;
} elsif ($f || $t || $r) {
my $err = 0;
if ($f) {
@from_fields = split(",", $f);
$err += check_fields(\@from_fields, %all_from_fields);
}
if ($r) {
@rel_fields = split(",", $r);
$err += check_fields(\@rel_fields, %all_rel_fields);
}
if ($t) {
@to_fields = split(",", $t);
$err += check_fields(\@to_fields, %all_to_fields);
}
( run in 0.800 second using v1.01-cache-2.11-cpan-39bf76dae61 )