Bio-KBase

 view release on metacpan or  search on metacpan

er_scripts/get_relationship_UsesAliasForCompound  view on Meta::CPAN

    -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 Source entity to return. Field-list is a comma-separated list of 
strings. The following fields are available:

=over 4

=item id

=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 alias

=back    

=item -to 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    

=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', 'alias' );
my @all_to_fields = ( 'id',  );

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_UsesAliasForCompound [-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.777 second using v1.01-cache-2.11-cpan-39bf76dae61 )