Beispiel #1
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
}
Beispiel #2
0
// CheckDREAMMV3IterItems 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
}