aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-peak-detection
blob: 002aaeca4ba28606dd22ea7926955458c202f7a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/perl -w

use strict;
use File::Basename;

my $only;
my $file;
my $start;

# Horrible option processing
if ( $ARGV[0] eq "--indexed" ) {
	$only = "indexed";
	$file = $ARGV[1];
	$start = 2;
} elsif ( $ARGV[0] eq "--not-indexed" ) {
	$only = "notindexed";
	$file = $ARGV[1];
	$start = 2;
} else {
	$only = "";
	$file = $ARGV[0];
	$start = 1;
}
my $args = join(" ", splice(@ARGV, $start, scalar(@ARGV)-1));
if ( !($args eq "") ) {
	printf("Extra arguments for hdfsee: %s\n", $args);
} else {
	# Default arguments - feel free to override!
	$args = "--binning=2 --int-boost=10";
	printf("Using default arguments for hdfsee: %s\n", $args);
}

open(FH, $file);
open(TMP, "> list.tmp");

my $in_image = 0;
my $line;
my $filename;
my $indexed;
while ( $line = <FH> ) {

	chomp $line;

	if ( $in_image ) {
		printf(TMP "%s\n", $line);
	}

	if ( $line =~ /^Peaks\ from\ peak\ search$/ ) {
		$in_image = 1;
	}

	if ( $line =~ /^Image\ filename:\ (.+)$/ ) {
		$filename = $1;
	}

	if ( $line =~ /^indexed_by\ =\ (.*)$/ ) {
		if ( $1 eq "none" ) {
			$indexed = 0;
		} else {
			$indexed = 1;
		}
	}

	if ( $line =~ /^End\ of\ peak\ list$/ ) {

		close(TMP);

		my $show;

		if ( $only eq "indexed" ) {
			if ( $indexed ) {
				$show = 1;
			} else {
				$show = 0;
			}
		} elsif ( $only eq "notindexed" ) {
			if ( $indexed ) {
				$show = 0;
			} else {
				$show = 1;
			}
		} else {
			$show = 1;
		}

		if ( !$show ) {
			printf(STDERR "Not showing %s\n", $filename);
			unlink("list.tmp");
			open(TMP, "> list.tmp");
			$in_image = 0;
			next;
		}

		# Example of how to do "basename" and "prefix":
		# $filename = "images-old/".basename($filename);

		printf(STDERR "Viewing %s\n", $filename);
		system("hdfsee ".$filename.
		       " --peak-overlay=list.tmp ".$args);
		if ( $? != 0 ) { exit; }
		unlink("list.tmp");
		open(TMP, "> list.tmp");
		$in_image = 0;

	}

}