Now you can specify '-' instead of input file name, and the script will read from stdin
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1422 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
0ec581080c
commit
843d7e6c8f
|
|
@ -14,6 +14,10 @@ sub usage {
|
||||||
print " The sort is stable. If -k option is not specified,\n";
|
print " The sort is stable. If -k option is not specified,\n";
|
||||||
print " it is assumed that the contig name is the first\n";
|
print " it is assumed that the contig name is the first\n";
|
||||||
print " field in each line.\n\n";
|
print " field in each line.\n\n";
|
||||||
|
print " INPUT input file to sort. If '-' is specified, \n";
|
||||||
|
print " then reads from STDIN.\n";
|
||||||
|
print " REF_DICT .fai file, or ANY file that has contigs, in the\n";
|
||||||
|
print " desired soting order, as its first column.\n";
|
||||||
print " --k POS : contig name is in the field POS (1-based)\n";
|
print " --k POS : contig name is in the field POS (1-based)\n";
|
||||||
print " of input lines.\n\n";
|
print " of input lines.\n\n";
|
||||||
|
|
||||||
|
|
@ -35,6 +39,7 @@ if ( scalar(@ARGV) != 2 ) {
|
||||||
my $input_file = $ARGV[0];
|
my $input_file = $ARGV[0];
|
||||||
my $dict_file = $ARGV[1];
|
my $dict_file = $ARGV[1];
|
||||||
|
|
||||||
|
|
||||||
open(DICT, "< $dict_file") or die("Can not open $dict_file: $!");
|
open(DICT, "< $dict_file") or die("Can not open $dict_file: $!");
|
||||||
|
|
||||||
my %ref_order;
|
my %ref_order;
|
||||||
|
|
@ -52,11 +57,16 @@ while ( <DICT> ) {
|
||||||
close DICT;
|
close DICT;
|
||||||
#we have loaded contig ordering now
|
#we have loaded contig ordering now
|
||||||
|
|
||||||
open(INPUT, "< $input_file") or die("Can not open $input_file: $!");
|
my $INPUT;
|
||||||
|
if ($input_file eq "-" ) {
|
||||||
|
$INPUT = "STDIN";
|
||||||
|
} else {
|
||||||
|
open($INPUT, "< $input_file") or die("Can not open $input_file: $!");
|
||||||
|
}
|
||||||
|
|
||||||
my %temp_outputs;
|
my %temp_outputs;
|
||||||
|
|
||||||
while ( <INPUT> ) {
|
while ( <$INPUT> ) {
|
||||||
|
|
||||||
my @fields = split '\s';
|
my @fields = split '\s';
|
||||||
die("Specified field position exceeds the number of fields:\n$_")
|
die("Specified field position exceeds the number of fields:\n$_")
|
||||||
|
|
@ -93,7 +103,7 @@ while ( <INPUT> ) {
|
||||||
print $fhandle $_; # send current line to its corresponding temp file
|
print $fhandle $_; # send current line to its corresponding temp file
|
||||||
}
|
}
|
||||||
|
|
||||||
close INPUT;
|
close $INPUT;
|
||||||
|
|
||||||
foreach my $f ( values %temp_outputs ) { close $f; }
|
foreach my $f ( values %temp_outputs ) { close $f; }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue