Reputation: 53
The common code is :
use strict;
use warnings;
my $f = $ARGV[0];
use Bio::EnsEMBL::Registry;
use Bio::EnsEMBL::ApiVersion;
my $registry = 'Bio::EnsEMBL::Registry';
$registry->load_registry_from_db(
-host => 'ensembldb.ensembl.org',
-user => 'anonymous',
-port => '5306'
);
my $adaptor = $registry->get_adaptor( 'Homo sapiens', 'core', 'transcript' );
my $transcript =
$adaptor->fetch_by_translation_stable_id($f);
LAST LINE
#For the LAST LINE, I am having trouble printing out the two values as two columns in the same line :
Attempt 1 code: print $f . $transcript->display_id. "\n";
Result : api.test.pl ENSP00000418690
ENSP00000418690ENST00000488594
Attempt 2 code :print $f, $transcript->display_id. "\n";
Result : perl api.test.pl ENSP00000418690 :
ENSP00000418690ENST00000488594
Any other attempt messes with accessing the display_id. What I want the format to be is : ENSP00000418690 ENST00000488594
Upvotes: 0
Views: 91
Reputation: 530852
Just to mention another possibility, you can two built-in perl variables.
{
local $, = " "; # Output field separator
local $\ = "\n"; # Output record separator
print $f, $transcript->display_id;
}
The output field separator is automatically printed between each argument in the list passed to print
. The output record separator is printed after the final argument to print
. Both are undefined by default, and interpreted to mean "don't print anything".
I declared them as local to a block as the simplest way of restricting them to the single print
statement.
Upvotes: 0
Reputation: 189317
If you want a space between the values, print a space between the values.
print $f, " ", $transcript->display_id, "\n";
The dot joins two strings into one string, which isn't necessary here, because print
accepts a comma-separated list of values.
Upvotes: 1