Skip to content
This repository has been archived by the owner on May 3, 2018. It is now read-only.

Commit

Permalink
Merge pull request #33 from mhalagan-nmdp/hackathon-updates
Browse files Browse the repository at this point in the history
Hackathon updates
  • Loading branch information
Michael Halagan committed Jan 13, 2017
2 parents 093e3e8 + ab10163 commit 8240a73
Show file tree
Hide file tree
Showing 43 changed files with 791 additions and 113 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ perl:
env:
global:
- PERL_MM_USE_DEFAULT=1
- "PATH=$PATH:$TRAVIS_BUILD_DIR:$TRAVIS_BUILD_DIR/hap1.1:/opt/ngs-tools/bin:$TRAVIS_BUILD_DIR/gfe_submission/bin"
- "PATH=$PATH:$TRAVIS_BUILD_DIR:$TRAVIS_BUILD_DIR/hap1.2:/opt/ngs-tools/bin:$TRAVIS_BUILD_DIR/gfe_submission/bin"
- NXF_VER='0.22.4'
- NXF_OPTS='-Xms512M -Xmx2G'

cache:
directories:
- perl_modules
- $TRAVIS_BUILD_DIR/hap1.1
- $TRAVIS_BUILD_DIR/hap1.2

before_install:
- sudo apt-get install -qyy openjdk-7-jre-headless perl-doc wget curl build-essential git libssl-dev
- export RELEASE_TESTING=1 AUTOMATED_TESTING=1 AUTHOR_TESTING=1 HARNESS_OPTIONS=c HARNESS_TIMER=1
- cp docker/hap1.1.tar.gz docker/ngs-tools_1.9.deb .
- cp docker/hap1.2.tar.gz docker/ngs-tools_1.9.deb .
- sudo dpkg --install ngs-tools_1.9.deb
- curl -fsSL get.nextflow.io | bash
- tar -xvzf hap1.1.tar.gz
- chmod a+x hap1.1/hap1.1.jar
- tar -xvzf hap1.2.tar.gz
- chmod a+x hap1.2/hap1.2.jar
- wget http://www.clustal.org/omega/clustalo-1.2.3-Ubuntu-x86_64
- mv clustalo-1.2.3-Ubuntu-x86_64 hap1.1/clustalo
- chmod a+x hap1.1/clustalo
- mv clustalo-1.2.3-Ubuntu-x86_64 hap1.2/clustalo
- chmod a+x hap1.2/clustalo
- cd GFE_Submission
- cpanm --quiet --notest --installdeps .
- cpanm --quiet --notest Devel::Cover::Report::Coveralls
Expand Down
4 changes: 2 additions & 2 deletions GFE_Submission/bin/app.pl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ =head1 LICENSE
$tokens->{'login_url'} = uri_for('/login');
$tokens->{'logout_url'} = uri_for('/logout');
$tokens->{'upload_url'} = uri_for('/upload');
$tokens->{'gfe_url'} = uri_for('/gfe');
$tokens->{'ars_reduxfile_url'} = uri_for('/gfe');
$tokens->{'gfe_url'} = uri_for('/gfe_gui');
$tokens->{'ars_reduxfile_url'} = uri_for('/gfe_gui');
};

dance;
Expand Down
150 changes: 150 additions & 0 deletions GFE_Submission/bin/breakup-fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/usr/bin/env perl
=head1 NAME
breakup-fasta
=head1 SYNOPSIS
=head1 AUTHOR Mike Halagan <mhalagan@nmdp.org>
Bioinformatics Scientist
3001 Broadway Stree NE
Minneapolis, MN 55413
ext. 8225
=head1 DESCRIPTION
=head1 CAVEATS
=head1 LICENSE
Copyright (c) 2016 National Marrow Donor Program (NMDP)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
> http://www.gnu.org/licenses/lgpl.html
=head1 VERSIONS
Version Description Date
=head1 TODO
=head1 SUBROUTINES
=cut
use strict; # always
use warnings; # or else
use FindBin;
use Data::Dumper;
use vars qw($USAGE);
BEGIN{

$| = 1;

$USAGE =
qq{./breakup-fasta [--fasta] [--uri] [--verbose] [--help]
-f/--fasta Fasta file
-u/--uri URI of feature service
-l/--locus HLA-Locus
-v/--verbose Flag for running in verbose
-h/--help
};

}
use Cwd;
use Math::Round;
my $n_id = getID();


my %h_seqs;
my $s_header;
my $s_seq;
while (<>) {
chomp;
if ($_ =~ />/) {
if ($s_seq) {
$h_seqs{$s_header} = $s_seq;
my $s_out_file = $n_id.".txt";
open(my $fh,">",$s_out_file) or die "CANT OPEN FILE $! $0";
print $fh ">".$s_header."\n";
print $fh $s_seq."\n";
close $fh;
$n_id = getID();
}
$s_header = $_;
$s_header =~ s/^>//; # remove ">"
$s_header =~ s/\s+$//; # remove trailing whitespace
if($s_header =~ m/ (\D{1,3}\d{0,1}\*\S+) /){
$s_header = "HLA-".$1;
}
$s_seq = ""; # clear out old sequence
}else {
s/\s+//g; # remove whitespace
$s_seq .= $_; # add sequence
}
}

if ($s_seq) { # handle last sequence
my $s_out_file = $n_id.".txt";
open(my $fh,">",$s_out_file) or die "CANT OPEN FILE $! $0";
print $fh ">".$s_header."\n";
print $fh $s_seq."\n";
close $fh;
}


sub getID{
my $id = int(rand(10000));
my $s_out_file = $id.".txt";
if(!-e $s_out_file){
return $id;
}else{
return getID();
}
}




























80 changes: 80 additions & 0 deletions GFE_Submission/bin/fasta.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env nextflow

params.fasta = ""
params.output = ""
params.name = ""
outputDir = file("${params.output}")

// Extracting consensus sequences
process extractConsensus{

tag{ expected }

input:
set file(expected) from file("${params.fasta}")

output:
set file('*.txt') into fastaFiles mode flatten

"""
breakup-fasta < ${expected}
"""
}


//Get GFE For each sequence
process getGFE{
errorStrategy 'ignore'

tag{ fastafile }

input:
set file(fastafile) from fastaFiles

output:
set file {"*.txt"} into gfeResults mode flatten

"""
cat ${fastafile} | fasta2structure
"""
}

gfeResults
.collectFile() { gfe ->
[ "${params.name}.txt", gfe.text ]
}
.subscribe { file -> copyToFailedDir(file) }


//Copy file to output directory
def copyToFailedDir (file) {
log.info "Copying ${file.name} into: $outputDir"
file.copyTo(outputDir)
def copiedFile = new File( "${params.output}/${file.name}" )
log.info copiedFile.name
if( !copiedFile.exists() ) {
log.info "Failed to copy file copiedFile.name ${file.name} into: $outputDir"
}else{
log.info "Copied $copiedFile ${file.name} into: $outputDir"
}
}

//Get subject id from fasta file
def subjectId(Path path) {
def name = path.getFileName().toString()
def subject = name.split('_')
return subject[0]
}

//Get subject id from fasta file
def blastSubjectId(Path path) {
def fileName = path.getFileName().toString()
def subject = fileName.split('.txt')
return subject[0]
}






Loading

0 comments on commit 8240a73

Please sign in to comment.