Commit 9497b2a1 authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 3.0.6+dfsg

parent 74886050
Loading
Loading
Loading
Loading
+45 −11
Original line number Diff line number Diff line
#! /usr/bin/perl

use IO::String;
use Getopt::Long;
#use Data::Dumper;

use lib '../lib';
use Bio::Tools::PSort::Report::Formatter;
use Bio::Tools::PSort;
use Bio::SeqIO;
use Bio::Tools::PSort::Constants qw(:all);

use Getopt::Long;
use Data::Dumper;

use strict;

our $ENV;
@@ -59,8 +61,8 @@ MAIN: {
  my $psort_analysis = 'psort';
  my $psort_output = 'bayes';

  my $root = '/usr/local/psortb-3.0';
  my $blastdir = '/usr/local/bio/blast';
  my $root = '/usr/local/psortb3';
  my $blastdir = '/usr/local/pkg/blast-2.2.26//bin';
  my $pftools = '/usr/local/bin/';
  my $pfscan_module = 'Profile';

@@ -365,7 +367,6 @@ MAIN: {
      die "We should never be here.\n";
    }


  } else {
    # Create a new PSort object.
    print(STDERR "* Using \"$server\" as remote PSort server\n")
@@ -378,18 +379,19 @@ MAIN: {

  # Figure out whether or not we're getting the sequences from a file or from
  # STDIN and open up a Bio::SeqIO on it.
  my $seqfh;
  if($fname) {
    if((-f $fname) && (-r $fname)) {
      print(STDERR "* Reading sequences from file \"$fname\"\n") if($verbose);
      open(SEQS, $fname) || die("Error: open $fname: $!\n");
      $sio = new Bio::SeqIO(-fh => \*SEQS, -format => $format);
      $seqfh = make_seq_input_uppercase($fname);
    } else {
      die("Error: file \"$fname\" doesn't exist or isn't readable\n");
    }
  } else {
    print(STDERR "* Reading sequences from STDIN\n") if($verbose);
    $sio = new Bio::SeqIO(-fh => \*STDIN, -format => $format);
    $seqfh = make_seq_input_uppercase();
  }
  $sio = new Bio::SeqIO(-fh => $seqfh, -format => $format);

  # Ready for prime time - go forth and PSort.
  my $format = new Bio::Tools::PSort::Report::Formatter();
@@ -404,3 +406,35 @@ MAIN: {
  }
  print($format->format($output, {-cutoff => $cutoff, -gram => $gram, -mcutoff => $divergent, -psort => $psort, -skiplocalizations => \@skippedlocalizations}, @reps));
}

sub make_seq_input_uppercase {

    my $fname = shift;

    my $seqinput;
    if (defined $fname) {
      open(SEQS, $fname) || die("Error: open $fname: $!\n");
      #$seqinput = <SEQS>;
      $seqinput = do { local $/; <SEQS> };
    } 
    else {
      $seqinput = <>;
    }

    # hack to convert sequences (not headers) to uppercase (lowercase 
    # seems to bring back no psortb results)
    my @seqs2uc = split(">", $seqinput);
    shift(@seqs2uc); # remove blank first element (after doing split on > where > is the first character)

    my $uc_seqs;
    foreach my $header_seq (@seqs2uc) {
      my ($h1, $s1) = split(/[\n\r]+/, $header_seq, 2);
      if ($s1 =~ /[a-z]/) {
        $s1 = uc($s1);
      }
      $uc_seqs .= ">$h1\n$s1";
    }
    
    my $seqfh = new IO::String($uc_seqs);
    return($seqfh);
}