Exemple #1
0
// CheckDREAMMV3GroupedItem tests the viz data directory for the
// presence/absence of the given file as part of grouped DREAMM V3 format
func CheckDREAMMV3GroupedItem(filePath string, haveItemProperty, noItem bool) error {
	if haveItemProperty && noItem {
		ok, err := file.IsEmpty(filePath)
		if err != nil {
			return err
		} else if !ok {
			return fmt.Errorf("file %s does not exist or is not empty", filePath)
		}
	} else if haveItemProperty && !noItem {
		ok, err := file.IsNonEmpty(filePath)
		if err != nil {
			return err
		} else if !ok {
			return fmt.Errorf("file %s is not non-empty", filePath)
		}
	}
	return nil
}
Exemple #2
0
// CheckDREAMMV3DXitems checks the presence of the correct dx files/symlinks
// in a given viz iteration directory.
// NOTE: lastProperty could refer to molecule orientations or regions for meshes
func CheckDREAMMV3DXItems(iter, lastPos, lastProperty, lastState int,
	hadFrame bool, fileTemplate string) error {

	pos := -1
	if lastPos >= 0 {
		pos = lastPos
	} else if lastProperty >= 0 {
		pos = lastProperty
	} else if lastState >= 0 {
		pos = lastState
	}

	fileName := fmt.Sprintf(fileTemplate, iter)
	if hadFrame {
		ok, err := file.IsNonEmpty(fileName)
		if err != nil {
			return err
		}
		if !ok {
			return fmt.Errorf("file %s is non non-empty as expected", fileName)
		}
	} else if pos >= 0 {
		fileTemplate := filepath.Join("../iteration_%d", filepath.Base(fileName))
		linkName := fmt.Sprintf(fileTemplate, pos)
		ok, err := file.IsSymLink(linkName, fileName)
		if err != nil {
			return err
		}
		if !ok {
			return fmt.Errorf("file %s is not properly symlinked to %s as expected",
				fileName, linkName)
		}
	} else {
		ok, err := file.NoFile(fileName)
		if err != nil {
			return err
		}
		if !ok {
			return fmt.Errorf("file %s exists but was expected to not be present",
				fileName)
		}
	}
	return nil
}
Exemple #3
0
// CheckDREAMMV2IterItems examines the viz iterations directory for
// a specific items (surface positions, orientations, etc.)
func CheckDREAMMV3IterItems(molSet, molIters *set.IntSet, iter, lastPos int,
	isEmpty bool, fileTemplate string) error {

	fileName := fmt.Sprintf(fileTemplate, iter)
	if molSet.Contains(iter) {
		if isEmpty {
			ok, err := file.Exists(fileName)
			if err != nil {
				return err
			} else if !ok {
				return fmt.Errorf("file %s does not exists", fileName)
			}
		} else {
			ok, err := file.IsNonEmpty(fileName)
			if err != nil {
				return err
			} else if !ok {
				return fmt.Errorf("file %s is not non-empty as expected", fileName)
			}
		}
	} else if lastPos >= 0 && !molIters.Contains(iter) {
		fileTemplate := filepath.Join("../iteration_%d", filepath.Base(fileName))
		linkName := fmt.Sprintf(fileTemplate, lastPos)
		ok, err := file.IsSymLink(linkName, fileName)
		if err != nil {
			return err
		} else if !ok {
			return fmt.Errorf("file %s is not properly symlinked to %s", fileName, linkName)
		}
	} else {
		ok, err := file.NoFile(fileName)
		if err != nil {
			return err
		} else if !ok {
			return fmt.Errorf("file %s exists but shouldn't", fileName)
		}
	}
	return nil
}
Exemple #4
0
// checkDREAMMV3Grouped checks the layout for DREAMM V3 grouped format
func checkDREAMMV3Grouped(testDir, dataDir string, numIters, numTimes int,
	haveMeshPos, haveRgnIdx, haveMeshState, noMeshes, haveMolPos, haveMolOrient,
	haveMolState, noMols bool) error {

	dataPath := filepath.Join(file.GetOutputDir(testDir), dataDir)

	// meshes
	meshPath := dataPath + ".mesh_positions.1.bin"
	if err := misc.CheckDREAMMV3GroupedItem(meshPath, haveMeshPos, noMeshes); err != nil {
		return err
	}

	regionPath := dataPath + ".region_indices.1.bin"
	if err := misc.CheckDREAMMV3GroupedItem(regionPath, haveRgnIdx, noMeshes); err != nil {
		return err
	}

	meshStatesPath := dataPath + ".mesh_states.1.bin"
	if err := misc.CheckDREAMMV3GroupedItem(meshStatesPath, haveMeshState,
		noMeshes); err != nil {
		return err
	}

	// molecules
	molPath := dataPath + ".molecule_positions.1.bin"
	if err := misc.CheckDREAMMV3GroupedItem(molPath, haveMolPos, noMols); err != nil {
		return err
	}

	orientPath := dataPath + ".molecule_orientations.1.bin"
	if err := misc.CheckDREAMMV3GroupedItem(orientPath, haveMolOrient, noMols); err != nil {
		return err
	}

	molStatesPath := dataPath + ".molecule_states.1.bin"
	if err := misc.CheckDREAMMV3GroupedItem(molStatesPath, haveMolState, noMols); err != nil {
		return err
	}

	// iterations
	iterPath := dataPath + ".iteration_numbers.1.bin"
	if numIters != 0 {
		ok, err := file.HasSize(iterPath, int64(numIters*12))
		if err != nil {
			return err
		}
		if !ok {
			return fmt.Errorf("file %s has incorrect file size", iterPath)
		}
	} else {
		ok, err := file.IsNonEmpty(iterPath)
		if err != nil {
			return err
		}
		if !ok {
			return fmt.Errorf("file %s is not non-empty", iterPath)
		}
	}

	// times
	timePath := dataPath + ".time_values.1.bin"
	if numTimes != 0 {
		ok, err := file.HasSize(timePath, int64(numTimes*8))
		if err != nil {
			return err
		}
		if !ok {
			return fmt.Errorf("file %s has incorrect file size", timePath)
		}
	} else {
		ok, err := file.IsNonEmpty(timePath)
		if err != nil {
			return err
		}
		if !ok {
			return fmt.Errorf("file %s is not non-empty", timePath)
		}
	}

	return nil
}