Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • thermophile
    Senior Member
    • Apr 2015
    • 243

    help with basemount copy script

    I have a script that I've cobbled together to copy fastq from each sample within a project into one folder on my computer.

    Code:
            for f in ../basemountpoint/basespace/Projects/PROJECTNAME/Samples/*/Files/*.gz;
            do cp $f PROJECTNAME"/fastq/"${f##*Files/};
            done
    This works, except for the occasions that I have to resequence a particular sample. Only the original sample is copied because basemount put " (2)" on the sample folder name for the second run. How can I tweak this so it will copy the fastq for the second run (the fastq are unique because they all get the run info as part of the name). I think I need to change this so the second part of the cp command ignores the " (2)" but can't figure out how. My first thought was to remove the * but that made it fail for all samples, not just the duplicates.

    Rereading the bash documentation isn't helping http://tldp.org/LDP/abs/html/string-manipulation.html
    Microbial ecologist, running a sequencing core. I have lots of strong opinions on how to survey communities, pretty sure some are even correct.
  • neavemj
    Member
    • Feb 2014
    • 58

    #2
    Hi thermophile,

    Can you give us the complete name of the old and new fastq files?

    The first line in that script is where the variable 'f' is assigned to each of the file names, so it might be at this point where the files with (2) are being missed.

    Cheers,

    Matt.

    Comment

    • Bukowski
      Senior Member
      • Jan 2010
      • 388

      #3
      Use rsync?

      Comment

      • thermophile
        Senior Member
        • Apr 2015
        • 243

        #4
        I don't want to just rsync because I need all the fastq in a single folder for downstream processing

        Here I've echo'd the cp line and added a comma for readability

        [CODE]for f in ../basemountpoint/basespace/Projects/PROJECTNAME/Samples/*/Files/*.gz;
        do echo $f "," "/PROJECTNAME"/fastq/"${f##*Files/};
        done
        [CODE]


        Code:
        ../basemountpoint/basespace/Projects/PROJECTNAME/Samples/ADB2017Dec13SI1 (2),/Files/ADB2017Dec13SI1_S150_L001_R1_001.fastq.gz PROJECTNAME/fastq/ADB2017Dec13SI1_S150_L001_R1_001.fastq.gz
        ../basemountpoint/basespace/Projects/PROJECTNAME/Samples/ADB2017Dec13SI1 (2),/Files/ADB2017Dec13SI1_S150_L001_R2_001.fastq.gz PROJECTNAME/fastq/ADB2017Dec13SI1_S150_L001_R2_001.fastq.gz
        ../basemountpoint/basespace/Projects/PROJECTNAME/Samples/ADB2017Dec13SI1,/Files/ADB2017Dec13SI1_S70_L001_R1_001.fastq.gz PROJECTNAME/fastq/ADB2017Dec13SI1_S70_L001_R1_001.fastq.gz
        ../basemountpoint/basespace/Projects/PROJECTNAME/Samples/ADB2017Dec13SI1,/Files/ADB2017Dec13SI1_S70_L001_R2_001.fastq.gz PROJECTNAME/fastq/ADB2017Dec13SI1_S70_L001_R2_001.fastq.gz
        Last edited by thermophile; 03-23-2018, 08:56 AM.
        Microbial ecologist, running a sequencing core. I have lots of strong opinions on how to survey communities, pretty sure some are even correct.

        Comment

        • neavemj
          Member
          • Feb 2014
          • 58

          #5
          Hi thermophile,

          I'd say the problem with the new file names are the extra space and the parentheses. The extra space makes it difficult for the 'cp' command to know what is the file to copy and what is the destination. Also, parentheses need to be 'escaped' if you want to use them in a filename. Something like the below (note the extra backslashes):

          ls ADB2017Dec13SI1\ \(2\)/

          This makes the whole thing pretty complicated, but I think if you put some quotes around the file names it will treat them as a whole rather than their parts:

          Code:
          for f in ../basemountpoint/basespace/Projects/PROJECTNAME/Samples/*/Files/*.gz;
                  do cp "$f" PROJECTNAME"/fastq/"${f##*Files/};
                  done
          The only thing I changed was to put the $f in quotes. I'm not entirely sure if this will work without actually trying it out. There are some other quotes in the 'destination' bit and some other things going on that might mess it up.

          Let me know if it works!

          Cheers,

          Matt.

          Comment

          • neavemj
            Member
            • Feb 2014
            • 58

            #6
            P.S. I guess the best idea would be to change your workflow so that spaces and parentheses are not introduced into the file names. If you use some linux programs for trimming or other processing, these will probably also fail with these file names.

            Good luck!

            Matt.

            Comment

            • fmd
              Junior Member
              • Nov 2018
              • 1

              #7
              For anyone that comes across this thread looking for help with BaseMount, I've made a Python script that might be useful to you. It doesn't exactly do what thermophile asked for, but should make retrieving the fastq files straightforward. Given a BaseMount project directory, it will extract all of the runs and simulate the folder structure you'd expect from a local MiSeq run for each. In addition to the reads, it will grab the sample sheet, InterOp directory contents, and log files.

              Here it is:

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                by SEQadmin2



                Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                ...
                Yesterday, 11:10 AM
              • SEQadmin2
                Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                by SEQadmin2



                Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                07-08-2026, 05:17 AM
              • GATTACAT
                Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                by GATTACAT
                Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                07-01-2026, 11:43 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, Yesterday, 10:04 AM
              0 responses
              11 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-08-2026, 10:08 AM
              0 responses
              9 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-07-2026, 11:05 AM
              0 responses
              16 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-02-2026, 11:08 AM
              0 responses
              31 views
              0 reactions
              Last Post SEQadmin2  
              Working...