Biomart Perl Api In Windows?
1
1
Entering edit mode
12.8 years ago
Manjulapra ▴ 70

Hi All, I am a Novice in perl and again in Biomart! I am trying to access COSMIC through Biomart. I am using a this code

use strict;

use BioMart::Initializer;
use BioMart::Query;
use BioMart::QueryRunner;

my $confFile ="C:/Users/Manjula/workspace/biomart-perl/conf/martDBLocation.xml";
print $confFile;


my $action='clean';
my $initializer = BioMart::Initializer->new('registryFile'=>$confFile, 'action'=>$action);
my $registry = $initializer->getRegistry;

my $query = BioMart::Query->new('registry'=>$registry,'virtualSchemaName'=>'default');


    $query->setDataset("COSMIC52B");
    $query->addFilter("hist_primary", ["adenoma"]);
    $query->addFilter("samp_gene_mutated", ["y"]);
    $query->addFilter("site_primary", ["small_intestine"]);
    $query->addAttribute("id_sample");
    $query->addAttribute("sample_name");
    $query->addAttribute("sample_source");
    $query->addAttribute("tumour_source");
    $query->addAttribute("gene_name");
    $query->addAttribute("accession_number");
    $query->addAttribute("id_mutation");
    $query->addAttribute("cds_mut_syntax");
    $query->addAttribute("aa_mut_syntax");
    $query->addAttribute("zygosity");
    $query->addAttribute("site_primary");
    $query->addAttribute("hist_primary");
    $query->addAttribute("pubmed_pmid");

$query->formatter("TSV");

my $query_runner = BioMart::QueryRunner->new();
############################## GET COUNT ############################
$query->count(1);
$query_runner->execute($query);
print $query_runner->getCount();
#####################################################################


############################## GET RESULTS ##########################
$query_runner->uniqueRowsOnly(1);

$query_runner->execute($query);
$query_runner->printHeader();
$query_runner->printResults();
$query_runner->printFooter();
#####################################################################

This is my Registry File!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MartRegistry>
<MartRegistry>

<MartDBLocation
                    name         = "msd_mart_4"
                    displayName  = "My BioMart Database"
                    databaseType = "mysql"
                    host         = "martdb.ebi.ac.uk"
                    port         = "3306"
                    database     = "msd_mart_4"
                    schema       = "msd_mart_4"
                    user         = "anonymous"
                    password     = ""
                    visible      = "1"
                    default      = ""
                    includeDatasets = ""
                    martUser     = ""
/>
</MartRegistry>

I know there is something wrong with the registry file, But I get a different error which I should attend first!

The syntax of the command is incorrect. 'cp' is not recognized as an internal or external command, operable program or batch file. Couldn't open C:/Users/Manjula/workspace/biomart-perl/conf/registryDOMXML: No such file or directory at C:/Perl64/lib/BioMart/Initializer.pm line 661

When I look it seems this line in Initializer.pm is causing this

system("cp $registryFile $copyRegistryFile");

I know that 'cp' is a Linux command. But I am running windows 7 with Eclipse Version: Helios Service Release 1 and EPIC 0.6.40

Any help is appreciated as I am stuck here for weeks.

Thanking in advance! Manjula

biomart perl api windows • 3.6k views
ADD COMMENT
1
Entering edit mode

Shouldn't the path of my $confFile contain backslashes instead of slashes?

ADD REPLY
1
Entering edit mode

Seems your problem is obvious. Linux commands aren't going to work under Windows. Either obtain Windows-specific versions of the package or use Linux.

ADD REPLY
0
Entering edit mode

..or use it from Cygwin. Did you download the .zip or the .tgz? (former should be for Windows)

ADD REPLY
4
Entering edit mode
12.8 years ago

although Perl is usually defined as a cross-platform programming language, as you only need the appropriate interpreter for your operating system, if you include platform specific commands on your code it will only work on that specific platform. for your particular case, in order to copy files through Perl maintaining its platform independence you will have to use the File::Copy module (which is included in a regular Perl distribution by default), since calling a system execution of "cp" would only work on Linux.

use File::Copy;
copy($registryFile, $copyRegistryFile) or die "Copy failed: $!";

regarding the path definition, there are ways of maintaining the platform independence through Perl, such as using the File::Spec module. Windows accepts both back and forward slashes as path delimiters, but keep in mind that if you use backslashes you must escape them by coupling them "\". I don't see an issue on your path definition, but it's strange that the file you are defining is

C:/Users/Manjula/workspace/biomart-perl/conf/martDBLocation.xml

and the error that is being reported refers to

C:/Users/Manjula/workspace/biomart-perl/conf/registry_DOM_XML

are you sure this error you are reporting here corresponds to the exact code above? because this later is the file that hasn't been found, and not the previous one which BioMart::Initializer seems to accept by not reporting any error.

ADD COMMENT
0
Entering edit mode

Thank you all, I got it working. Installed Cygwin and initially tried with Interpreter type Cygwin selected in EPIC settings at Eclipse Preferences. Did not work, then used normal interpreter type and now it's working. The difference of the paths are due to a line in Initializer.pm which refer to registry_DOM_XML file. Actually the error get raised at that line due non functional 'cp' Now I am getting a "Can not connect to Database" error which I should attend to! :-)

Thank You all again,

Regards, Manjula

ADD REPLY

Login before adding your answer.

Traffic: 1515 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6