Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7703007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:21:40+00:00 2026-05-31T23:21:40+00:00

I am trying to achieve a pattern matching in perl code. I will give

  • 0

I am trying to achieve a pattern matching in perl code. I will give an example so it is easier to explain.

I am trying to use the following link in samtools -view:

ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/data/HG00132/alignment/HG00132.mapped.SOLID.bfast.GBR.low_coverage.20111114.bam

samtools allows only a specific datasline to be retrieved with the following syntax:

samtools view -h ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/data/HG00132/alignment/HG00132.mapped.SOLID.bfast.GBR.low_coverage.20111114.bam 1:123-1234

There are 1000 of them and the ‘GBR’ bit of the link changes. So I wrote a simple perl script and replace the link with ‘ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/data/HG00132/alignment/HG00132.mapped.SOLID.bfast.*.bam’. But it does not recognize the link. So I was wondering if there is similar way of using * in unix which you can use in the middle of the text rather than at the end. So I want to replace GBR with a star and also keep the ‘bam’ bit at the far end of the file name (I do not need to download the file.)

Thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:21:41+00:00Added an answer on May 31, 2026 at 11:21 pm

    Use LWP to browse FTP. There are no hyper-links, so you have to parse the listing to distinguish among files you want to mirror. Shell globs like * do not work, but regex are suitable.

    Untested example: collecting all bam URIs from the specified directory.

    use File::Listing qw(parse_dir);
    use LWP::UserAgent qw();
    
    my @bam_files;
    
    my $base = 'ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/data/HG00132/alignment/';
    my $ua = LWP::UserAgent->new;
    my $index = $ua->get($base);
    for my $entry (parse_dir $index->decoded_content) {
        my $filename = $entry->[0];
        next unless $filename =~ /bam$/;
        push @bam_files, $base . $filename;
    }
    

    It is impossible to use an FTP file without downloading it first (see method get in LWP::UserAgent). This does not imply saving it also on the local filesystem (that would be method mirror).

    samtools must do this behind the scenes, too, perhaps using protocol extensions to download only ranges, not the full file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to achieve something google isn't able to give answer. I'm trying to
Regular expressions allows for the pattern matching syntax shown below. I'm trying to implement
I will try and explain exactly what I want to achieve first. Imagine two
I'm trying to write some replacement regex that will insert a locale code into
I'm trying to extract a substring matching a given pattern from a string in
Trying to achieve any moving effect while appending an element from one to another
im trying to achieve something but i dont really know how I have set
I am trying to achieve better performance for my Java SWT application, and I
What I am trying to achieve is a form that has a button on
What I'm trying to achieve is to determine if the Postscript that I'm parsing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.