Page 2 of 2 First 12
  • Jump to page:
    #16
  1. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,221
    Rep Power
    1809
    Originally Posted by Laurent_R
    The one thing, though, I am thinking about is that your probes file had lines starting with ">", and your code does not remove any such character. If you still have these '>' in your probes file, it can't work the way it is now. You need to change the relevant line as follows:

    Perl Code:
    $line =~ s/[\r\n>]//g;


    to also remove '>' from input (only needed on the probe file, not required on the data file).
    That is correct. This other line should have been removed also as it's putting a bad string in @seqs which you won't want to be testing for.

    Code:
    my @seqs = "Flanks/ALL_HITS_TEST.txt";
    I've done it in the script below which is working with the tiny example files given:

    Code:
    #!/usr/bin/env perl
    use strict;
    use warnings;
    
    use Data::Dumper;
    
    my $hfile = "Flanks/ALL_HITS_TEST.txt";
    my $gfile = "Flanks/SampleGenome.txt";
    my @seqs;
    
    open my $hfh, '<', $hfile or die "Could not open file $hfile: $!";
    while (<$hfh> ) {
    	chomp;
    	s/^>//;
    	push @seqs, $_;
    }
    close $hfh;
    
    #print Dumper \@seqs;
    
    open my $gfh, '<', $gfile or die "Could not open file $gfile: $!";
    while (<$gfh>) {
    	chomp;
    	next if /^\s*$/;
    	
    	foreach my $probe (@seqs) {
    		if (/$probe/) {
    			# I'm not capturing probe. You already have it.
    			# What would be the point?
    			print "'$probe' found in $_\n\n";
    			last;	# isn't checking if other sequences also present
    		}
    	}
    }
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    776
    Rep Power
    495
    Originally Posted by keath
    Code:
    # ...
    open my $hfh, '<', $hfile or die "Could not open file $hfile: $!";
    while (<$hfh> ) {
    # ...
    By the way, Adam, notice how Keath is using the same syntax for opening files that I recommended to you?

Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo