Created
May 26, 2016 23:29
-
-
Save JohnLonginotto/422f60545d690a12b5ce032058581e02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
open( IN_P1, "/Users/John/Desktop/ENCFF001LCU.fq" ) or die "File not found"; | |
$| = 1; | |
my $yup = 0; | |
my $barcode1 = 'AATTCCGGAATT'; | |
my $barcode1_regex = make_barcode_fragments( $barcode1 ); | |
while ( defined( my $firstp1 = <IN_P1> ) ) { | |
my $p1_first_line = $firstp1; | |
my $p1_second_line = <IN_P1>; | |
my $p1_third_line = <IN_P1>; | |
my $p1_fourth_line = <IN_P1>; | |
chomp( $p1_first_line, $p1_second_line, $p1_third_line, $p1_fourth_line, ); | |
my $matched_R1 = "$p1_first_line\n$p1_second_line\n$p1_third_line\n$p1_fourth_line\n"; | |
if ( $p1_second_line =~ /$barcode1_regex/i ) { $yup++; } | |
} | |
# make two mismatch patterm of barcode | |
sub make_barcode_fragments { | |
my ($in1) = @_; | |
my @subpats; | |
for my $i ( 0 .. length($in1) - 1 ) { | |
for my $j ( $i + 1 .. length($in1) - 1 ) { | |
my $subpat = join( '', | |
substr( $in1, 0, $i ), | |
'\\w', substr( $in1, $i + 1, $j - $i - 1 ), | |
'\\w', substr( $in1, $j + 1 ), | |
); | |
push @subpats, $subpat; | |
} | |
} | |
my $pat = join( '|', @subpats ); | |
#print $pat; | |
return "$pat"; | |
} | |
print $yup; | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment