Last active
January 17, 2019 01:46
-
-
Save srynobio/7e5b32abc20229f4743368c8b3cb461f 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/env perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
use autodie; | |
open( my $FILE, '<', $ARGV[0] ) or die; | |
( my $individual = $ARGV[0] ) =~ s/\.data.prep.txt//g; | |
open(my $OUT, '>>', "$individual.align.txt") or die; | |
foreach my $line (<$FILE>) { | |
chomp $line; | |
next if ( $line =~ /^SAMPLE/ ); | |
my @parts = split /\t/, $line; | |
my $alignLine; | |
my ( $file1, $file2, $sm, $id, $lb, $pu, $pl ); | |
if ( $parts[7] eq 'PAIRED' ) { | |
$file1 = $parts[1]; | |
$file2 = $parts[2]; | |
$sm = $parts[0]; | |
$id = $parts[11]; | |
$lb = $parts[12]; | |
$pu = $parts[13]; | |
$pl = $parts[8]; | |
$alignLine = sprintf( | |
"Files=%s,%s;Type=PAIRED;RG=\@RG\\tID:%s\\tSM:%s\\tLB:%s\\tPL:%s\\tPU:%s", | |
$file1, $file2, $id, $sm, $lb, $pl, $pu ); | |
} | |
elsif ( $parts[7] eq 'UNPAIRED' ) { | |
$file1 = $parts[1]; | |
$sm = $parts[0]; | |
$id = $parts[11]; | |
$lb = $parts[12]; | |
$pu = $parts[13]; | |
$pl = $parts[8]; | |
$alignLine = sprintf( | |
"Files=%s;Type=UNPAIRED;RG=\@RG\\tID:%s\\tSM:%s\\tLB:%s\\tPL:%s\\tPU:%s", | |
$file1, $id, $sm, $lb, $pl, $pu ); | |
} | |
say $OUT $alignLine; | |
} | |
close($FILE); | |
close($OUT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment