diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 00000000..0f1b551c --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,4 @@ +^.*\.Rproj$ +^\.Rproj\.user$ +^tests/ +^\.github/ \ No newline at end of file diff --git a/.github/scripts/update_version_tag.py b/.github/scripts/update_version_tag.py new file mode 100644 index 00000000..1db7a270 --- /dev/null +++ b/.github/scripts/update_version_tag.py @@ -0,0 +1,26 @@ +import os +import sys +import re + + +def main(): + r_directory = "../../R/" + current_timestamp = sys.argv[1] + version_comment = f"#version=\"{current_timestamp}\"\n" + + for filename in os.listdir(r_directory): + file_path = os.path.join(r_directory, filename) + + if os.path.isfile(file_path): + with open(file_path, 'r') as file: + lines = file.readlines() + + if len(lines) >= 4 and re.match("^#version", lines[3]): + lines[3] = version_comment + with open(file_path, 'w') as file: + file.writelines(lines) + print(f"Version comment updated to current UTC: {filename}") + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 3742b457..84e078de 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -3,8 +3,14 @@ on: push: branches: [main, master] + paths: + - "R/**" + - "tests/**" pull_request: branches: [main, master] + paths: + - "R/**" + - "tests/**" name: R-CMD-check diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml new file mode 100644 index 00000000..0ac050a3 --- /dev/null +++ b/.github/workflows/create-release.yaml @@ -0,0 +1,155 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ["CHANGELOG.md"] + +name: create-release + +jobs: + release-documentation: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CHANGELOG: "CHANGELOG.md" + DESCRIPTION: "DESCRIPTION" + outputs: + version: ${{ steps.extract-version.outputs.version }} + steps: + - uses: actions/checkout@v3 + + - name: Extract release version from first level 4 heading + id: extract-version + run: | + version=$(grep -oP '####[^0-9]*\K\d+\.\d+\.\d+' -m 1 $CHANGELOG) + echo "version=$version" >> $GITHUB_ENV + echo "version=$version" >> $GITHUB_OUTPUT + echo "Version: $version" + + - name: Get current UTC timestamp + id: get-timestamp + run: | + timestamp=$(date -u +"%Y.%m.%d.%H%M") + echo "timestamp=$timestamp" >> $GITHUB_ENV + echo "Timestamp: $timestamp" + + - name: Standardize first level 4 heading + id: update-change-header + run: | + timestamp=$(echo "${{ env.timestamp }}" | awk -F'.' '{print $1"."$2"."$3}') + sed -i "0,/^####.*$/s/^####.*$/#### Version ${{ env.version }} \($timestamp\)/" $CHANGELOG + echo "CHANGELOG Timestamp: $timestamp" + + - name: Update DESCRIPTION `Version` and `Date` + id: update-description + run: | + timestamp=$(echo "${{ env.timestamp }}" | awk -F'.' '{print $1"-"$2"-"$3}') + sed -i "s|^Date:.*$|Date: $timestamp|" $DESCRIPTION + sed -i "s|^Version:.*$|Version: ${{ env.version }}|" $DESCRIPTION + echo "DESCRIPTION Timestamp: $timestamp" + + - name: Update `version` comments on R files + id: update-r-version-comment + run: | + cd .github/scripts + chmod +x update_version_tag.py + python update_version_tag.py ${{ env.timestamp }} + + - name: Commit and push changes + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add ./R/*.R + git add DESCRIPTION + git add CHANGELOG.md + git commit -m "Updated documentation for release" || echo "No changes to commit" + git pull --ff-only + git push origin + + release-build: + runs-on: ubuntu-latest + needs: release-documentation + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CHANGELOG: "CHANGELOG.md" + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-tinytex@v2 + - run: tlmgr --version + + - name: Install additional LaTeX packages + run: | + tlmgr install preprint + tlmgr install listings + tlmgr install tcolorbox + tlmgr install pgf + tlmgr install environ + tlmgr install tikzfill + tlmgr install pdfcol + tlmgr install grfext + tlmgr list --only-installed + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: "release" + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - name: Build R package + run: | + R CMD build --compact-vignettes=gs+qpdf . + tar_file="$(find . -maxdepth 1 -type f -name '*.tar.gz' -print -quit | sed 's|^\./||')" + artifacts="artifacts" + mkdir $artifacts + mv $tar_file "$artifacts/" + echo "tar_file=$artifacts/$tar_file" >> $GITHUB_ENV + echo "asset_name=$tar_file" >> $GITHUB_ENV + + - name: Make release properties + id: release-fields + run: | + version="${{ needs.release-documentation.outputs.version }}" + echo "version=$version" >> $GITHUB_ENV + echo "Version: $version" + tag="v${version}" + echo "tag=$tag" >> $GITHUB_ENV + echo "Tag: $tag" + name="Version ${version}" + echo "name=$name" >> $GITHUB_ENV + echo "Name: $name" + body="$(awk '/^\*.*$/{print; next} /^####/{count++; if(count==2) exit}' $CHANGELOG)" + echo "body<> "$GITHUB_ENV" + echo "$body" >> "$GITHUB_ENV" + echo "EOF" >> "$GITHUB_ENV" + echo "Body: $body" + + - name: Create Release + id: create-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.tag }} + release_name: ${{ env.name }} + draft: false + prerelease: false + body: | + ${{ env.body }} + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create-release.outputs.upload_url }} + asset_path: ${{ env.tar_file }} + asset_name: ${{ env.asset_name }} + asset_content_type: application/gzip diff --git a/CHANGELOG.md b/CHANGELOG.md index d68f1df4..f2fa6f0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ CHANGELOG --------- -#### Version 1.0.7 (2024.01.25) -* list by Greg here +#### Version 1.0.7 (2024.02.01) +* More robust parsing of feature sequence locations using INSDC standards +* Exception handling for attempted reading of GenBank data +* "Repair" GenBank data with unqualified features to handle `read.gb` bug +* Preemptively checks for presence of data property necessary for specified analysis, with `logger` info in case of issues #### Version 1.0.6 (2024.01.07) * Moved functions reg. IRs, quadripartite structure into separate file diff --git a/DESCRIPTION b/DESCRIPTION index 1c9435d1..b5217231 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: PACVr Version: 1.0.7 -Date: 2024-01-25 +Date: 2024-02-01 Title: Plastome Assembly Coverage Visualization Authors@R: c(person("Gregory", "Smith", role=c("ctb")), person("Nils", "Jenke", role=c("ctb")), diff --git a/R/IRoperations.R b/R/IRoperations.R index 890ef0c7..74ee979f 100644 --- a/R/IRoperations.R +++ b/R/IRoperations.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" checkIREquality <- function(gbkData, regions, dir, sample_name) { gbkSeq <- read.gbSeq(gbkData) diff --git a/R/PACVr.R b/R/PACVr.R index 397de0c8..f66098e2 100644 --- a/R/PACVr.R +++ b/R/PACVr.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" PACVr.read.gb <- function(gbkFile) { gbkRaw <- getGbkRaw(gbkFile) diff --git a/R/customizedRCircos.R b/R/customizedRCircos.R index 8b06e06b..1bf43803 100644 --- a/R/customizedRCircos.R +++ b/R/customizedRCircos.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" # The following R functions were taken from the R package RCircos and then modified. diff --git a/R/customizedRead.gb.R b/R/customizedRead.gb.R index a1093037..3bacfa86 100644 --- a/R/customizedRead.gb.R +++ b/R/customizedRead.gb.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" read.gbWithHandling <- function(gbkRaw, count=0) { gbkData <- tryCatch({ diff --git a/R/generatePlotData.R b/R/generatePlotData.R index dfea2a15..b547bfd7 100644 --- a/R/generatePlotData.R +++ b/R/generatePlotData.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" CovCalc <- function(bamFile, windowSize = 250) { # Calculates coverage of a given bam file and stores data in data.frame format diff --git a/R/helpers.R b/R/helpers.R index 7f15a8e0..2cb58410 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" read.gb2DF <- function(gbkData, regionsCheck) { fileDF <- data.frame() diff --git a/R/parseData.R b/R/parseData.R index c309d2dc..f2f29a9a 100644 --- a/R/parseData.R +++ b/R/parseData.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" ExtractAllGenes <- function(gbkDataDF) { # Function to extract gene information from Genbank flatfile data diff --git a/R/quadripartiteOperations.R b/R/quadripartiteOperations.R index 58e1c11f..1d08cdd3 100644 --- a/R/quadripartiteOperations.R +++ b/R/quadripartiteOperations.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" FilterByKeywords <- function(allRegions, where) { # Function to filter list based on genomic keywords diff --git a/R/visualizeWithRCircos.R b/R/visualizeWithRCircos.R index 59e6d3a1..e0235504 100644 --- a/R/visualizeWithRCircos.R +++ b/R/visualizeWithRCircos.R @@ -1,7 +1,7 @@ #!/usr/bin/env RScript #contributors=c("Gregory Smith", "Nils Jenke", "Michael Gruenstaeudl") #email="m_gruenstaeudl@fhsu.edu" -#version="2024.01.25.1500" +#version="2024.02.01.0322" visualizeWithRCircos <- function(plotTitle, genes,