Leser: 22
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
#!/usr/bin/perl
use warnings;
my $file = "test.txt";
my @x;
my @id;
my @marker;
my @allelA;
my @allelB;
my @quality;
my @probA;
my @probB;
my $laenge_x;
my $file_mach = "test2.txt";
my @mach;
my @id_mach;
my @marker_mach;
my @allelA_mach;
my @allelB_mach;
my @quality_mach;
my @probA_mach;
my @probB_mach;
my $laenge_mach;
open( IN, "<$file" ) or die "Konnte Input nicht oeffnen!\n";
while (<IN>) {
chomp($_);
@x = split(/\t/, $_ );
push(@id, $x[0]);
push(@marker, $x[1]);
push(@allelA, $x[2]);
push(@allelB, $x[3]);
push(@quality, $x[4]);
push(@probA, $x[5]);
push(@probB, $x[6]);
}
close(IN);
open (IN2, "<$file_mach");
while (<IN2>) {
chomp($_);
@mach = split(/\t/, $_ );
push(@id_mach, $mach[0]);
push(@marker_mach, $mach[1]);
push(@allelA_mach, $mach[2]);
push(@allelB_mach, $mach[3]);
push(@quality_mach, $mach[6]);
push(@probA_mach, $mach[4]);
push(@probB_mach, $mach[5]);
}
close(IN2);
my $together = 0;
my $mach = 0;
my $x = 0;
for my $i (1..$#id){
for my $j (1..$#id_mach){
if ( $id[$i] eq $id_mach[$j] and
$marker[$i] eq $marker_mach[$j] and
$allelA[$i] eq $allelA_mach[$j] and
$allelB[$i] eq $allelB_mach[$j])
{
$together++;
}
}
}
print $together;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use strict;
use warnings;
use FileHandle;
use Data::Dumper qw/Dumper/;
my $file = 'test.txt';
my $fh = FileHandle->new();
my @ids = ();
if( $fh->open($file, "<") ) {
while( my $line = $fh->getline() ) {
my ($id) = $line =~ m/^((?:[^\t]+\t){3}[^\t]+)/;
push @ids, $id;
}
$fh->close();
}else{
die("Error reading file $file: $!");
}
print Dumper \@ids;