root/galaxy-central/tools/filters/joinWrapper.pl

リビジョン 2, 1.0 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1#! /usr/bin/perl -w
2
3use strict;
4use warnings;
5use File::Temp "tempfile";
6
7my ($input1, $input2, $field1, $field2, $mode, $OOption, $out_file1) = @ARGV;
8
9die "No arguments\n" unless @ARGV == 7;
10
11my ($fh1, $file1) = tempfile();
12my ($fh2, $file2) = tempfile();
13
14`sort -k $field1 $input1 > $file1`;
15`sort -k $field2 $input2 > $file2`;
16
17my $option = "";
18my @fields = ();
19my $line = "";
20
21if ($OOption eq "Y") {
22  if (defined($fh1)) {
23    $line = <$fh1>;
24  } else {
25    die "Failed to create file $file1\n";
26  }
27  @fields = split /\t/, $line;
28  die "The field you selected does not exist in the input file" if (@fields < $field1);
29  my @optionO = ();
30  my $i = 0;
31  foreach (@fields) {
32    ++$i;
33    push(@optionO, "1.$i");
34  }
35  $option = "-o " . join(",", @optionO);
36} else {
37  $option = "";
38}
39
40$ENV{'LC_ALL'} = 'POSIX';
41
42if ($mode eq "V") {
43  `join -v 1 $option -1 $field1 -2 $field2 $file1 $file2 | tr " " "\t" > $out_file1`;
44} else {
45  `join $option -1 $field1 -2 $field2 $file1 $file2 | tr " " "\t" > $out_file1`;
46}
47
48`rm $file1 ; rm $file2`;
49
50
51
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。