This notebook will build you a Galaxy tool_dependencies.xml file for Perl packages.

Insert you package name into cell 1 and cell 4. A typical package name looks like 'HTTP::Client'.


In [1]:
perl_package_name = 'HTTP::Client'
toolshed_package_name = 'perl_http_client'
toolshed_package_version = '1.57'

In [2]:
!cpanm CPAN::FindDependencies


!
! Can't write to /usr/local/share/perl/5.20.1 and /usr/local/bin: Installing modules to /home/bag/perl5
! To turn off this warning, you have to do one of the following:
!   - run me as a root or with --sudo option (to install to /usr/local/share/perl/5.20.1 and /usr/local/bin)
!   - Configure local::lib your existing local::lib in this shell to set PERL_MM_OPT etc.
!   - Install local::lib by running the following commands
!
!         cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!
CPAN::FindDependencies is up to date. (2.42)

In [3]:
!export PERL5LIB=$HOME/perl5/lib/perl5

In [4]:
%%perl --out output --err error
use CPAN::FindDependencies;
@deps = CPAN::FindDependencies::finddeps('HTTP::Client');
foreach my $dep (@deps) {
    print ' ' x $dep->depth;
    print "http://www.cpan.org/authors/id/", $dep->distribution(), "\n";
}

In [5]:
from string import Template

In [6]:
template = Template("""
<tool_dependency>
    <package name="perl" version="5.18.1">
        <repository name="package_perl_5_18" owner="iuc" prior_installation_required="True" />
    </package>
    <package name="$toolshed_name" version="$toolshed_version">
        <install version="1.0">
            <actions>
                <action type="setup_perl_environment">
                    <repository name="package_perl_5_18" owner="iuc">
                        <package name="perl" version="5.18.1" />
                    </repository>
$package
                </action>
            </actions>
        </install>
        <readme><![CDATA[
            Perl package: $readme
        ]]>
        </readme>
    </package>
</tool_dependency>
""")

In [7]:
package_content = []
for line in output.split():
    line = line.strip()
    if line:
        package_content.append( '                    <package>%s</package>' % line )

content = dict(
            readme=perl_package_name, 
            package='\n'.join( reversed(package_content) ),
            toolshed_name=toolshed_package_name,
            toolshed_version=toolshed_package_version
        )
print template.substitute(content)


<tool_dependency>
    <package name="perl" version="5.18.1">
        <repository name="package_perl_5_18" owner="iuc" prior_installation_required="True" />
    </package>
    <package name="perl_http_client" version="1.57">
        <install version="1.0">
            <actions>
                <action type="setup_perl_environment">
                    <repository name="package_perl_5_18" owner="iuc">
                        <package name="perl" version="5.18.1" />
                    </repository>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/WWW-RobotRules-6.02.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GB/GBARR/IO-1.25.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/M/MS/MSCHILLI/Net-HTTP-6.07.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/P/PE/PEVANS/Socket-2.016.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/S/SH/SHAY/libnet-3.04.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/HTTP-Negotiate-6.01.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/HTTP-Daemon-6.01.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/E/ET/ETHER/URI-1.65.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/LWP-MediaTypes-6.02.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/D/DL/DLAND/File-Path-2.09.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/D/DA/DAGOLDEN/File-Temp-0.2304.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/C/CJ/CJM/IO-HTML-1.001.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/P/PM/PMQS/Compress-Raw-Bzip2-2.068.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/P/PM/PMQS/IO-Compress-2.068.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/P/PM/PMQS/Compress-Raw-Zlib-2.068.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/HTTP-Message-6.06.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/HTTP-Cookies-6.01.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/P/PE/PETDANCE/HTML-Tagset-3.20.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/HTML-Parser-3.71.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/D/DR/DROLSKY/Time-Local-1.2300.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/HTTP-Date-6.02.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/File-Listing-6.04.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/Encode-Locale-1.03.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/S/SA/SAPER/XSLoader-0.16.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/MIME-Base64-3.14.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/Digest-1.17.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/G/GA/GAAS/Digest-MD5-2.53.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/M/MS/MSCHILLI/libwww-perl-6.08.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/A/AD/ADAMK/LWP-Online-1.08.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/M/MU/MUIR/modules/Text-Tabs+Wrap-2013.0523.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/J/JE/JESSE/Test-1.26.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/N/NE/NEILB/Pod-Escapes-1.07.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/D/DW/DWHEELER/Pod-Simple-3.28.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/R/RR/RRA/podlators-2.5.3.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/S/SM/SMUELLER/PathTools-3.47.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/D/DA/DANKOGAI/Encode-2.67.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/B/BI/BINGOS/ExtUtils-MakeMaker-7.04.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/N/NE/NEILB/HTTP-Lite-2.43.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/C/CO/CORION/parent-0.228.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/R/RJ/RJBS/perl-5.18.4.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/L/LE/LEONT/Test-Harness-3.34.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/P/PE/PEVANS/Scalar-List-Utils-1.41.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/E/EX/EXODIST/Test-Simple-1.001014.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/R/RJ/RJBS/perl-5.20.0.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/T/TO/TODDR/Exporter-5.70.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/Z/ZE/ZEFRAM/Carp-1.3301.tar.gz</package>
                    <package>http://www.cpan.org/authors/id/N/NE/NEILB/HTTP-Client-1.57.tar.gz</package>
                </action>
            </actions>
        </install>
        <readme><![CDATA[
            Perl package: HTTP::Client
        ]]>
        </readme>
    </package>
</tool_dependency>


In [ ]: