Changeset 5930


Ignore:
Timestamp:
May 6, 2020, 9:43:30 AM (4 weeks ago)
Author:
Nicklas Nordborg
Message:

Fixes #1241: Some folders for external samples are not changed to the specified group

Location:
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java

    r5903 r5930  
    417417 
    418418  /**
     419    Get the prefix from the name. A prefix is a
     420    number of letters/numbers followed by an underscore.
     421    Returns null if the name has no prefix.
     422    @since 4.27
     423  */
     424  public static String getPrefix(String name)
     425  {
     426    int i = name.indexOf('_');
     427    return i > 0 ? name.substring(0, i) : null;
     428  }
     429 
     430  /**
    419431    Mark all related files for removal.
    420432    @since 2.16
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/CufflinksJobCreator.java

    r5790 r5930  
    502502      if (externalGroup != null)
    503503      {
    504         script.cmd("chgrp -R " + externalGroup + " ${CufflinksFolder} 2>> ${WD}/chgrp.out || echo [" + rawName +"] >> ${WD}/chgrp.out");
     504        ScriptUtil.addChgrp(externalGroup, "${CufflinksFolder}", rawName, null, script);
    505505      }
    506506      script.cmd("ls -1 ${CufflinksFolder}/* >> ${WD}/files.out");
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/HisatAlignJobCreator.java

    r5791 r5930  
    444444      if (externalGroup != null)
    445445      {
    446         script.cmd("chgrp -R " + externalGroup + " ${HisatFolder} 2>> ${WD}/chgrp.out || echo [" + alignedName +"] >> ${WD}/chgrp.out");
     446        ScriptUtil.addChgrp(externalGroup, "${HisatFolder}", alignedName, null, script);
    447447      }
    448448      script.cmd("ls -1 ${HisatFolder}/* >> ${WD}/files.out");
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/MBafJobCreator.java

    r5618 r5930  
    251251      if (externalGroup != null)
    252252      {
    253         script.cmd("chgrp -R " + externalGroup + " ${BamFolder}/mbaf* 2>> ${WD}/chgrp.out || echo [" + aligned.getName() +"] >> ${WD}/chgrp.out" );
     253        ScriptUtil.addChgrp(externalGroup, "${BamFolder}/mbaf*", aligned.getName(), null, script);
    254254      }
    255255
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/MipsAlignJobCreator.java

    r5843 r5930  
    413413      if (externalGroup != null)
    414414      {
    415         script.cmd("chgrp -R " + externalGroup + " ${AlignFolder} 2>> ${WD}/chgrp.out || echo [" + alignedName +"] >> ${WD}/chgrp.out");
     415        ScriptUtil.addChgrp(externalGroup, "${AlignFolder}", alignedName, null, script);
    416416      }
    417417      script.cmd("ls -1 ${AlignFolder}/* >> ${WD}/files.out");
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/MipsDemuxJobCreator.java

    r5865 r5930  
    367367        if (externalGroup != null)
    368368        {
    369           script.cmd("chgrp -R " + externalGroup + " " + fastqFolder + " 2>> ${WD}/chgrp.out || echo [" + mergeName +"] >> ${WD}/chgrp.out");
     369          ScriptUtil.addChgrp(externalGroup, fastqFolder, mergeName, archiveRoot+"/"+Reggie.getPrefix(mergeName), script);
    370370        }
    371371       
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/RnaSeqDemuxJobCreator.java

    r5865 r5930  
    450450        if (externalGroup != null)
    451451        {
    452           script.cmd("chgrp -R " + externalGroup + " " + fastqFolder + " 2>> ${WD}/chgrp.out || echo [" + mergeName +"] >> ${WD}/chgrp.out");
     452          ScriptUtil.addChgrp(externalGroup, fastqFolder, mergeName, archiveRoot+"/"+Reggie.getPrefix(mergeName), script);
    453453        }
    454454
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/ScriptUtil.java

    r5619 r5930  
    7171  }
    7272
     73  /**
     74    Add a 'chgrp' command to set the group of the given 'folder' and all files and subdirectories in it.
     75    If a 'parentFolder' is given and is a parent folder of the 'folder' a 'chgrp' command is added
     76    to parent folder up to (but not including) the parent folder. Errors are logged to ${WD}/chgrp.out.
     77    'itemName' is used for logging errors only
     78    @since 4.27
     79  */
     80  public static void addChgrp(String groupName, String folder, String itemName, String parentFolder, ScriptBuilder script)
     81  {
     82    // Make sure parent folder ends with '/' and folder doesn't so that the while loop breaks correctly
     83    if (folder.endsWith("/")) folder = folder.substring(0, folder.length()-1);
     84    if (parentFolder != null && !parentFolder.endsWith("/")) parentFolder += "/";
     85
     86    script.cmd("chgrp -R " + groupName + " " + folder + " 2>> ${WD}/chgrp.out || echo [" + itemName +"] >> ${WD}/chgrp.out");
     87
     88    while (parentFolder != null)
     89    {
     90      int last = folder.lastIndexOf('/');
     91      if (last == -1) break;
     92      folder = folder.substring(0, last); // Move up one directory: /foo/bar/x --> /foo/bar
     93      // Check if we have reached the parent folder
     94      if (folder.indexOf(parentFolder) == -1) break;
     95     
     96      script.cmd("chgrp " + groupName + " " + folder + " 2>> ${WD}/chgrp.out || echo [" + itemName +"] >> ${WD}/chgrp.out");
     97    }
     98  }
     99 
    73100  /**
    74101    We only allow letters, numbers, dot, underscore and forward slash in path names.
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/StringTieJobCreator.java

    r5790 r5930  
    297297      if (externalGroup != null)
    298298      {
    299         script.cmd("chgrp -R " + externalGroup + " ${StringTieFolder} 2>> ${WD}/chgrp.out || echo [" + rawName +"] >> ${WD}/chgrp.out");
     299        ScriptUtil.addChgrp(externalGroup, "${StringTieFolder}", rawName, null, script);
    300300      }
    301301      script.cmd("ls -1 ${StringTieFolder}/* >> ${WD}/files.out");
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/VariantCallingJobCreator.java

    r5877 r5930  
    502502        if (externalGroup != null)
    503503        {
    504           script.cmd("chgrp -R " + externalGroup + " ${BamFolder}/variants-* 2>> ${WD}/chgrp.out || echo [" + aligned.getName() +"] >> ${WD}/chgrp.out" );
     504          ScriptUtil.addChgrp(externalGroup, "${BamFolder}/variants-*", aligned.getName(), null, script);
    505505        }
    506506      }
     
    515515        if (externalGroup != null)
    516516        {
    517           script.cmd("chgrp -R " + externalGroup + " ${FilteredFolder}/* 2>> ${WD}/chgrp.out || echo [" + aligned.getName() +"] >> ${WD}/chgrp.out" );
     517          ScriptUtil.addChgrp(externalGroup, "${FilteredFolder}", aligned.getName(), null, script);
    518518        }
    519519      }
Note: See TracChangeset for help on using the changeset viewer.