Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/rc'
Browse files Browse the repository at this point in the history
For release version 3.6.15
  • Loading branch information
evolarjun committed Mar 31, 2020
2 parents 7e7d99a + 46ea558 commit af5a52f
Show file tree
Hide file tree
Showing 16 changed files with 759 additions and 240 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: binary tarball

on: [release]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: setup
run: sudo apt-get install -y hmmer ncbi-blast+ curl build-essential
- name: download
run: bash -x .github/workflows/get_binary_release.sh
- name: where are we
run: |
pwd
ls -al
- name: test protein
run: |
./amrfinder --plus -p test_prot.fa -g test_prot.gff -O Escherichia > test_prot.got
diff test_prot.expected test_prot.got
- name: test dna
run: |
./amrfinder --plus -n test_dna.fa -O Escherichia --mutation_all test_dna_mut_all.got > test_dna.got
diff test_dna.expected test_dna.got
- name: test combined
run: |
./amrfinder --plus -n test_dna.fa -p test_prot.fa -g test_prot.gff -O Escherichia > test_both.got
diff test_both.expected test_both.got
35 changes: 35 additions & 0 deletions .github/workflows/get_binary_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# found and lightly modified these functions
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" |
grep '"tag_name":' |
cut -d '"' -f 4
}

get_tarball_url() {
curl --silent "https://api.github.com/repos/$1/releases/latest" |
fgrep '"browser_download_url":' |
cut -d '"' -f 4
}


release=$(get_latest_release ncbi/amr)
URL=$(get_tarball_url ncbi/amr)

# download and unpack AMRFinder binaries
curl --silent -L -O $URL
tarball_name=$(echo $URL | perl -pe 's#^.*/(.*)#\1#')
tar xfz $tarball_name
rm $tarball_name

# download and unpack test
curl --silent \
-O https://raw.githubusercontent.com/ncbi/amr/master/test_dna.fa \
-O https://raw.githubusercontent.com/ncbi/amr/master/test_prot.fa \
-O https://raw.githubusercontent.com/ncbi/amr/master/test_prot.gff \
-O https://raw.githubusercontent.com/ncbi/amr/master/test_both.expected \
-O https://raw.githubusercontent.com/ncbi/amr/master/test_dna.expected \
-O https://raw.githubusercontent.com/ncbi/amr/master/test_prot.expected

# download database
./amrfinder --update
43 changes: 43 additions & 0 deletions .github/workflows/mac_conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Mac bioconda test
on:
push:
branches:
- master
- rc
schedule:
- cron: '30 3 * * *' # 3:30am everyday

jobs:
build:

runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: download conda
run: curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
- name: install conda
run: |
bash ./Miniconda3-latest-MacOSX-x86_64.sh -b -p /Users/runner/miniconda3
source /Users/runner/miniconda3/bin/activate
conda init
- name: install AMRFinderPlus
run: |
source /Users/runner/miniconda3/bin/activate
conda install -y -c bioconda ncbi-amrfinderplus
- name: Download AMRFinderPlus database
run: /Users/runner/miniconda3/bin/amrfinder -u
- name: test protein
run: |
source /Users/runner/miniconda3/bin/activate
amrfinder --plus -p test_prot.fa -g test_prot.gff -O Escherichia > test_prot.got
diff test_prot.expected test_prot.got
- name: test dna
run: |
source /Users/runner/miniconda3/bin/activate
amrfinder --plus -n test_dna.fa -O Escherichia --mutation_all test_dna_mut_all.got > test_dna.got
diff test_dna.expected test_dna.got
- name: test combined
run: |
source /Users/runner/miniconda3/bin/activate
amrfinder --plus -n test_dna.fa -p test_prot.fa -g test_prot.gff -O Escherichia > test_both.got
diff test_both.expected test_both.got
108 changes: 97 additions & 11 deletions alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Mutation::Mutation (size_t pos_arg,
QC_ASSERT (! contains (name, " "));

// reference, allele
parse (geneMutation, reference, allele);
parse (geneMutation, reference, allele, gene);
if (allele == "STOP")
allele = "*";
else if (allele == "del")
Expand All @@ -79,13 +79,15 @@ Mutation::Mutation (size_t pos_arg,
QC_ASSERT (reference != allele);
QC_ASSERT (! contains (reference, '-'));
QC_ASSERT (! contains (allele, '-'));
QC_ASSERT (! gene. empty ());
}



void Mutation::parse (const string &geneMutation,
string &reference,
string &allele)
string &allele,
string &gene)
{
QC_ASSERT (! geneMutation. empty ());
QC_ASSERT (reference. empty ());
Expand Down Expand Up @@ -117,6 +119,9 @@ void Mutation::parse (const string &geneMutation,
{
Common_sp::reverse (allele);
Common_sp::reverse (reference);
QC_ASSERT (c == '_');
QC_ASSERT (i);
gene = geneMutation. substr (0, i);
return;
}
break;
Expand All @@ -129,6 +134,7 @@ void Mutation::parse (const string &geneMutation,

bool Mutation::operator< (const Mutation &other) const
{
LESS_PART (*this, other, gene);
LESS_PART (*this, other, pos);
LESS_PART (*this, other, geneMutation);
return false;
Expand All @@ -140,6 +146,22 @@ bool Mutation::operator< (const Mutation &other) const
// SeqChange


SeqChange::SeqChange (const Alignment* al_arg,
size_t targetStopPos)
: al (al_arg)
, start (al->targetSeq. size () - 1)
, len (1)
, reference (string (1, al->refSeq. back ()))
, allele (string (1, al->refSeq. back ()) + "*")
, start_ref (al->refEnd - 1)
, stop_ref (al->refEnd)
, start_target (targetStopPos - 1)
{
ASSERT (al->targetProt);
ASSERT (al->refProt);
}


void SeqChange::qc () const
{
if (! qc_on)
Expand All @@ -158,7 +180,9 @@ void SeqChange::qc () const
QC_ASSERT (start_ref < stop_ref);
QC_ASSERT (stop_ref <= al->refEnd);
QC_ASSERT (reference. size () * al->al2ref_len <= stop_ref - start_ref);
QC_ASSERT (start_target < al->targetEnd);
QC_ASSERT (start_target <= al->targetEnd);
QC_ASSERT (prev != '-');
QC_IMPLY (reference. empty (), prev);
}


Expand All @@ -173,6 +197,7 @@ bool SeqChange::operator< (const SeqChange &other) const

bool SeqChange::better (const SeqChange &other) const
{
LESS_PART (other, *this, hasMutation ());
LESS_PART (*this, other, neighborhoodMismatch);
LESS_PART (other, *this, al->pIdentity ());
return false;
Expand All @@ -197,6 +222,11 @@ bool SeqChange::finish (const string &refSeq,
setStartTarget ();
if (flankingLen)
setNeighborhoodMismatch (flankingLen);
if (reference. empty ())
{
QC_ASSERT (start);
prev = refSeq [start - 1];
}
if (verbose ())
saveText (cout);
return neighborhoodMismatch <= 0.04; // PAR // PD-3191
Expand Down Expand Up @@ -584,6 +614,7 @@ void Alignment::setSeqChanges (const Vector<Mutation> &refMutations,
rfindSplit (s, pm_delimiter); // Only gene symbol
const string pmGene (s);


{
SeqChange seqChange (this);
bool inSeqChange = false;
Expand All @@ -608,19 +639,30 @@ void Alignment::setSeqChanges (const Vector<Mutation> &refMutations,
inSeqChange = true;
}
}
if ( targetProt
&& refProt
&& targetEnd == targetLen
&& refEnd < refLen
)
{
SeqChange seqChange (this, targetLen);
seqChanges << move (seqChange);
}
if (verbose ())
PRINT (seqChanges. size ());


Vector<SeqChange> seqChanges_add;
//Vector<SeqChange> seqChanges_add;
size_t j = 0;

while (j < refMutations. size () && refMutations [j]. pos < refStart)
{
if (allMutationsP)
seqChanges_add << SeqChange (this, & refMutations [j]);
//if (allMutationsP)
//seqChanges_add << SeqChange (this, & refMutations [j]);
j++;
}

// SeqChange::mutation
size_t start_ref_prev = NO_INDEX;
for (SeqChange& seqChange : seqChanges)
{
Expand All @@ -636,9 +678,11 @@ void Alignment::setSeqChanges (const Vector<Mutation> &refMutations,
cout << "Processing Mutation: ";
mut. print (cout);
}
#if 0
if (mut. pos < seqChange. start_ref)
if (allMutationsP)
seqChanges_add << SeqChange (this, & mut); // "seqChanges <<" destroys seqChange
#endif
if (mut. getStop () > seqChange. stop_ref)
break;
if (seqChange. matchesMutation (mut))
Expand All @@ -655,22 +699,48 @@ void Alignment::setSeqChanges (const Vector<Mutation> &refMutations,
start_ref_prev = seqChange. start_ref;
}

seqChanges << move (seqChanges_add);
//seqChanges << move (seqChanges_add);

#if 0
if (allMutationsP)
while (j < refMutations. size ())
{
seqChanges << SeqChange (this, & refMutations [j]);
j++;
}

for (Iter<Vector<SeqChange>> it (seqChanges); it. next ();)
if (! it->mutation)
it. erase ();
#endif

if (allMutationsP)
{
size_t refPos = refStart;
size_t i = 0;
for (const Mutation& mut : refMutations)
{
while (refPos < mut. pos)
{
ASSERT (refSeq [i] != '-');
i++;
while (refSeq [i] == '-')
i++;
if (! refSeq [i])
break;
refPos++;
}
if (! refSeq [i])
break;
if ( refPos == mut. pos
&& isLeft (string (& refSeq [i]), mut. reference)
&& isLeft (string (& targetSeq [i]), mut. reference)
)
seqChanges << SeqChange (this, & mut);
}
}

seqChanges. sort ();
if (verbose ())
{
cout << endl;
cout << targetName << " vs. " << refName << ":" << endl;
cout << "All found mutations:" << endl;
for (const SeqChange& seqChange : seqChanges)
seqChange. saveText (cout);
Expand All @@ -683,6 +753,22 @@ void Alignment::qc () const
{
if (! qc_on)
return;

if (empty ())
{
QC_ASSERT (targetName. empty ());
QC_ASSERT (targetSeq. empty ());
QC_ASSERT (! targetStart);
QC_ASSERT (! targetEnd);
QC_ASSERT (! targetLen);
QC_ASSERT (refName. empty ());
QC_ASSERT (refSeq. empty ());
QC_ASSERT (! refStart);
QC_ASSERT (! refEnd);
QC_ASSERT (! refLen);
QC_ASSERT (! nident);
return;
}

QC_ASSERT (targetSeq. size () == refSeq. size ());

Expand Down
Loading

0 comments on commit af5a52f

Please sign in to comment.