コード例 #1
0
ファイル: DataLoader.cpp プロジェクト: zhanxw/rvtests
/**
 * according to the order of @param vcfSampleNames, put phenotypes to @param
 * phenotypeInOrder
 * @param imputePhenotype: if true, we will impute phenotpye to the average
 * for
 * those have genotype but no phenotype;
 *                         if false, we will drop those samples
 */
void rearrange(const std::map<std::string, double>& phenotype,
               const std::vector<std::string>& vcfSampleNames,
               std::vector<std::string>* vcfSampleToDrop,
               std::vector<std::string>* phenotypeNameInOrder,
               std::vector<double>* phenotypeValueInOrder,
               bool imputePhenotype) {
  vcfSampleToDrop->clear();
  phenotypeNameInOrder->clear();
  phenotypeValueInOrder->clear();

  if (!isUnique(vcfSampleNames)) {
    logger->error("VCF file have duplicated sample id. Quitting!");
    abort();
  }
  if (!imputePhenotype) {
    for (size_t i = 0; i < vcfSampleNames.size(); i++) {
      if (phenotype.count(vcfSampleNames[i]) == 0) {
        vcfSampleToDrop->push_back(vcfSampleNames[i]);
      } else {
        phenotypeNameInOrder->push_back(
            phenotype.find(vcfSampleNames[i])->first);
        phenotypeValueInOrder->push_back(
            phenotype.find(vcfSampleNames[i])->second);
      }
    }
  } else {
    double sum = 0.0;
    int nMissingPheno = 0;
    for (size_t i = 0; i < vcfSampleNames.size(); i++) {
      if (phenotype.count(vcfSampleNames[i]) == 0) {
        ++nMissingPheno;
      } else {
        sum += phenotype.find(vcfSampleNames[i])->second;
      }
    }
    double avg = sum / (vcfSampleNames.size() - nMissingPheno);
    for (size_t i = 0; i < vcfSampleNames.size(); i++) {
      if (phenotype.count(vcfSampleNames[i]) == 0) {
        logger->info("Impute phenotype of sample [ %s ] to [ %g ]",
                     vcfSampleNames[i].c_str(), avg);
        phenotypeNameInOrder->push_back(vcfSampleNames[i]);
        phenotypeValueInOrder->push_back(avg);
      } else {
        phenotypeNameInOrder->push_back(
            phenotype.find(vcfSampleNames[i])->first);
        phenotypeValueInOrder->push_back(
            phenotype.find(vcfSampleNames[i])->second);
      }
    }
    if (nMissingPheno)
      logger->warn(
          "Impute [ %d ] missing phenotypes for samples with genotypes but "
          "lacks phenotypes",
          nMissingPheno);
  }
}
コード例 #2
0
ファイル: DataLoader.cpp プロジェクト: marisacgarre/rvtests
int _loadCovariate(const std::string& fn,
                   const std::vector<std::string>& includedSample,
                   const std::string& covNameToUse,
                   DataLoader::HandleMissingCov handleMissingCov,
                   SimpleMatrix* covariate, std::vector<std::string>* colNames,
                   std::set<std::string>* sampleToDrop) {
  std::vector<std::string> fd;
  if (covNameToUse.size()) {
    stringTokenize(covNameToUse, ',', &fd);
  }
  if (!isUnique(fd)) {
    logger->error("Remove duplicated covariates in the model before continue");
    return -1;
  }
  if (!isUnique(includedSample)) {
    logger->error("Unable to include duplicated samples");
    return -1;
  }
  return _loadCovariate(fn, includedSample, fd, handleMissingCov, covariate,
                        colNames, sampleToDrop);
}
コード例 #3
0
ファイル: SecurityOrigin.cpp プロジェクト: Moondee/Artemis
void SecurityOrigin::grantLoadLocalResources()
{
    // Granting privileges to some, but not all, documents in a SecurityOrigin
    // is a security hazard because the documents without the privilege can
    // obtain the privilege by injecting script into the documents that have
    // been granted the privilege.
    //
    // To be backwards compatible with older versions of WebKit, we also use
    // this function to grant the ability to load local resources to documents
    // loaded with SubstituteData.
    ASSERT(isUnique() || SecurityPolicy::allowSubstituteDataAccessToLocal());
    m_canLoadLocalResources = true;
}
コード例 #4
0
bool SecurityOrigin::isThirdParty(const SecurityOrigin* child) const
{
    if (child->m_universalAccess)
        return false;

    if (this == child)
        return false;

    if (isUnique() || child->isUnique())
        return true;

    return !isSameSchemeHostPort(child);
}
コード例 #5
0
ファイル: command.cpp プロジェクト: VladimirZhandarov/exaro
bool  AddDomObject::isUnique(QObject * object, QObject * ownerObject, const QString & name ) const
{
	if (!object)
		return true;

	if (object->objectName() == name && ownerObject!=object)
		return false;

	for (int i = 0;i < object->children().size();i++)
		if (!isUnique(object->children()[i], ownerObject, name))
			return false;
	return true;
}
コード例 #6
0
bool SecurityOrigin::isPotentiallyTrustworthy() const
{
    ASSERT(m_protocol != "data");
    if (isUnique())
        return m_isUniqueOriginPotentiallyTrustworthy;

    if (SchemeRegistry::shouldTreatURLSchemeAsSecure(m_protocol) || isLocal() || isLocalhost())
        return true;

    if (SecurityPolicy::isOriginWhiteListedTrustworthy(*this))
        return true;

    return false;
}
コード例 #7
0
	void SortedSetContainer<T>::add(const T& elem)
	{
		string m;
		m = "SortedSetContainer object must consist of unique elements.\n";
		
		if(isUnique(elem))
		{
			this->list.push_back(elem);
			++this->size;
			sort(this->list.begin(), this->list.end());
		}
		else
			throw m;
	}
コード例 #8
0
ファイル: question1_1_v3.c プロジェクト: dilrajssokhi/ctci
int main(int argc, char *argv[]){
    // Firstly check the arguments
    if(argc != 2){
        printf("Invalid arguments.n\n");
        printf("Usage: %s test_stringn\n",argv[0]);
        return 1;
    }
    // Use the argument as test string
    bool testret = isUnique(argv[1]);
    if(testret == true)
        printf("%s: is unique.n\n",argv[1]);
    else
        printf("%s: is not unique.n\n",argv[1]);
    return 0;
}
コード例 #9
0
ファイル: set_manager-utest.cpp プロジェクト: ggeorgiev/dbs
TEST(SetManagerTest, isUnique)
{
    doim::LocationSetSPtr locations;
    ASSERT_TRUE(locations->isUnique());

    locations = doim::LocationSet::make();

    auto location = doim::Location::obtain(nullptr, "/isUnique");
    locations->insert(location);

    ASSERT_FALSE(locations->isUnique());

    locations = doim::LocationSet::unique(locations);
    ASSERT_TRUE(location->isUnique());
}
コード例 #10
0
	SortedSetContainer<T>::SortedSetContainer(const vector<T>& orig)
	{
		this->size = 0;
		// setVector function updates the size inside
		for (int i = 0; i < orig.size(); i++)
		{
			if(isUnique(orig.at(i)))
			{
				this->list.push_back(orig.at(i));
				++this->size;
			}
		}
		sort(this->list.begin(), this->list.end());
		listIterator = 0;
	}
コード例 #11
0
std::string ResourceURIFactory::makeUniqueURI(const std::string &uri)
{
    std::lock_guard<std::mutex> lock(m_lock);
    if (isUnique(uri))
    {
        updateUri(uri);
        return uri;
    }
    std::ostringstream os;
    os << uri;
    if (!uri.empty() && '/' != uri[uri.length() - 1])
        os << '/';
    os << m_id++;
    updateUri(os.str());
    return os.str();
}
コード例 #12
0
ファイル: security_origin.cpp プロジェクト: vasi/kdelibs
bool SecurityOrigin::canRequest(const KUrl& url) const
{
    if (isUnique())
        return false;

    WTF::RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url);
    if (targetOrigin->isUnique())
        return false;

    // We call isSameSchemeHostPort here instead of canAccess because we want
    // to ignore document.domain effects.
    if (isSameSchemeHostPort(targetOrigin.get()))
        return true;

    return false;
}
コード例 #13
0
ファイル: SecurityOrigin.cpp プロジェクト: Moondee/Artemis
bool SecurityOrigin::canAccess(const SecurityOrigin* other) const
{
    if (m_universalAccess)
        return true;

    if (this == other)
        return true;

    if (isUnique() || other->isUnique())
        return false;

    // Here are two cases where we should permit access:
    //
    // 1) Neither document has set document.domain. In this case, we insist
    //    that the scheme, host, and port of the URLs match.
    //
    // 2) Both documents have set document.domain. In this case, we insist
    //    that the documents have set document.domain to the same value and
    //    that the scheme of the URLs match.
    //
    // This matches the behavior of Firefox 2 and Internet Explorer 6.
    //
    // Internet Explorer 7 and Opera 9 are more strict in that they require
    // the port numbers to match when both pages have document.domain set.
    //
    // FIXME: Evaluate whether we can tighten this policy to require matched
    //        port numbers.
    //
    // Opera 9 allows access when only one page has set document.domain, but
    // this is a security vulnerability.

    bool canAccess = false;
    if (m_protocol == other->m_protocol) {
        if (!m_domainWasSetInDOM && !other->m_domainWasSetInDOM) {
            if (m_host == other->m_host && m_port == other->m_port)
                canAccess = true;
        } else if (m_domainWasSetInDOM && other->m_domainWasSetInDOM) {
            if (m_domain == other->m_domain)
                canAccess = true;
        }
    }

    if (canAccess && isLocal())
       canAccess = passesFileCheck(other);

    return canAccess;
}
コード例 #14
0
bool SecurityOrigin::canAccessStorage(const SecurityOrigin* topOrigin) const
{
    if (isUnique())
        return false;

    // FIXME: This check should be replaced with an ASSERT once we can guarantee that topOrigin is not null.
    if (!topOrigin)
        return true;

    if (m_storageBlockingPolicy == BlockAllStorage || topOrigin->m_storageBlockingPolicy == BlockAllStorage)
        return false;

    if ((m_storageBlockingPolicy == BlockThirdPartyStorage || topOrigin->m_storageBlockingPolicy == BlockThirdPartyStorage) && topOrigin->isThirdParty(this))
        return false;

    return true;
}
コード例 #15
0
ファイル: func.cpp プロジェクト: mediaprojects/hiphop-php
bool Func::isNameBindingImmutable(const Unit* fromUnit) const {
  if (RuntimeOption::EvalJitEnableRenameFunction ||
      m_attrs & AttrDynamicInvoke) {
    return false;
  }

  if (isBuiltin()) {
    return true;
  }

  if (isUnique() && RuntimeOption::RepoAuthoritative) {
    return true;
  }

  // Defined at top level, in the same unit as the caller. This precludes
  // conditionally defined functions and cross-module calls -- both phenomena
  // can change name->Func mappings during the lifetime of a TC.
  return top() && (fromUnit == m_unit);
}
コード例 #16
0
ファイル: helpiface.hpp プロジェクト: jinoos/qt-screenshot
/*!
	Mark unrequired part of the name with '[' and ']'
	characters.
*/
inline void
markUnrequiredPartOfTheName(
	//! Name to mark unrequired part.
	QString & name,
	//! All available names.
	const QStringList & rawNames )
{
	int index = 1;

	while( !isUnique( name.left( index ), rawNames )
		&& index < name.length() )
			++index;

	if( index != name.length() )
	{
		name.insert( index, QLatin1Char( '[' ) );
		name.append( QLatin1Char( ']' ) );
	}
} // markUnrequiredPartOfTheName
コード例 #17
0
/*!
    Returns a deep-copied clone of the QMofStructuralFeature.
*/
QModelingElement *QMofStructuralFeature::clone() const
{
    QMofStructuralFeature *c = new QMofStructuralFeature;
    c->asQModelingObject()->setObjectName(this->asQModelingObject()->objectName());
    c->asQModelingObject()->setProperty("role", this->asQModelingObject()->property("role"));
    foreach (QMofComment *element, ownedComments())
        c->addOwnedComment(dynamic_cast<QMofComment *>(element->clone()));
    c->setName(name());
    c->setVisibility(visibility());
    c->setLeaf(isLeaf());
    c->setStatic(isStatic());
    c->setOrdered(isOrdered());
    c->setUnique(isUnique());
    if (lowerValue())
        c->setLowerValue(dynamic_cast<QMofValueSpecification *>(lowerValue()->clone()));
    if (upperValue())
        c->setUpperValue(dynamic_cast<QMofValueSpecification *>(upperValue()->clone()));
    c->setReadOnly(isReadOnly());
    return c;
}
コード例 #18
0
ファイル: Monster.cpp プロジェクト: ronw23/prime-osx
const char *
shMonster::an ()
{
    char *buf = GetBuf ();

    if (!Hero.canSee (this) and !Hero.canHearThoughts (this)) {
        strncpy (buf, hasMind () ? "someone" : "something", SHBUFLEN);
    } else if (isUnique ()) {
        return the ();
    } else if (Hero.is (kXenosHunter) and isXenos ()) {
        snprintf (buf, SHBUFLEN, "a xenos scum");
    } else if (Hero.is (kXenosHunter) and isHeretic ()) {
        snprintf (buf, SHBUFLEN, "a heretic");
    } else {
        snprintf (buf, SHBUFLEN,
                  isvowel (myIlk ()->mName[0]) ? "an %s" : "a %s",
                  myIlk ()->mName);
    }
    return buf;
}
コード例 #19
0
ファイル: UmlRelation.cpp プロジェクト: javrillon/douml
void UmlRelation::gen_uml_decl()
{
    if (isClassMember())
        fw.write("static, ");

    write(visibility());
    writeq(roleName());
    fw.write(" : ");
    roleType()->write();

    QByteArray s;

    s = defaultValue();

    if (!s.isEmpty()) {
        if (s[0] != '=')
            fw.write(" = ");

        writeq(s);
    }

    s = multiplicity();

    if (!s.isEmpty()) {
        fw.write(", multiplicity : ");
        writeq(s);
    }

    if (isDerived())
        fw.write((isDerivedUnion()) ? ", derived union" : ", derived");

    if (isReadOnly())
        fw.write(", read only");

    if (isOrdered())
        fw.write(", ordered");

    if (isUnique())
        fw.write(", unique");

}
コード例 #20
0
bool SecurityOrigin::isSameSchemeHostPort(const SecurityOrigin* other) const
{
    if (this == other)
        return true;

    if (isUnique() || other->isUnique())
        return false;

    if (m_host != other->m_host)
        return false;

    if (m_protocol != other->m_protocol)
        return false;

    if (m_port != other->m_port)
        return false;

    if (isLocal() && !passesFileCheck(other))
        return false;

    return true;
}
コード例 #21
0
ファイル: SecurityOrigin.cpp プロジェクト: Moondee/Artemis
bool SecurityOrigin::canRequest(const KURL& url) const
{
    if (m_universalAccess)
        return true;

    if (isUnique())
        return false;

    RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url);

    if (targetOrigin->isUnique())
        return false;

    // We call isSameSchemeHostPort here instead of canAccess because we want
    // to ignore document.domain effects.
    if (isSameSchemeHostPort(targetOrigin.get()))
        return true;

    if (SecurityPolicy::isAccessWhiteListed(this, targetOrigin.get()))
        return true;

    return false;
}
コード例 #22
0
ファイル: UmlPinParameter.cpp プロジェクト: SciBoy/douml
void UmlPinParameter::html(Q3CString pfix, unsigned int rank, unsigned int level) {
  if (isUnique()) {
    if (isException())
      fw.write("<p>Unique, exception</p>");
    else
      fw.write("<p>Read only</p>");
  }
  else if (isException())
    fw.write("<p>Exception</p>");

  fw.write("<p>Direction : ");
  write(direction());
  fw.write("</p>");

  if (effect() != noEffect) {
    fw.write("<p>Effect : ");
    write(effect());
    fw.write("</p>");
  }

  html_internal(pfix, rank, level);

}
コード例 #23
0
ファイル: security_origin.cpp プロジェクト: vasi/kdelibs
QString SecurityOrigin::toString() const
{
    if (isEmpty())
        return "null";

    if (isUnique())
        return "null";

    if (m_protocol == "file")
        return QString("file://");

    QString result;
    result += m_protocol;
    result += "://";
    result += m_host;

    if (m_port) {
        result += ":";
        result += QString::number(m_port);
    }
    
    return result;
}
コード例 #24
0
int main()
{
	char str[1000];
	int len, flag;
	
	while (gets(str)) {
		len = strlen(str);
		flag = isUnique(str, len);

		if (flag)
			printf("unique!\n");
		else
			printf("repeat!\n");


		flag = isUniqueBitmap(str, len);
		if (flag)
			printf("unique!\n");
		else
			printf("repeat!\n");
	}

	return 0;
}
コード例 #25
0
String SecurityOrigin::toString() const
{
    if (isUnique())
        return "null";

    if (m_protocol == "file") {
        if (m_enforceFilePathSeparation)
            return "null";
        return "file://";
    }

    StringBuilder result;
    result.reserveCapacity(m_protocol.length() + m_host.length() + 10);
    result.append(m_protocol);
    result.append("://");
    result.append(m_host);

    if (m_port) {
        result.append(":");
        result.append(String::number(m_port));
    }

    return result.toString();
}
コード例 #26
0
ファイル: test_p.cpp プロジェクト: pamirs/edo
void verifySolution()
{
    CPPUNIT_ASSERT(isUnique(std::string("sdfhgf"))  == false);
    CPPUNIT_ASSERT(isUnique(std::string("abcdef"))  == true);
    CPPUNIT_ASSERT(isUnique(std::string("aaaaaaaa")) == false);
    CPPUNIT_ASSERT(isUnique(std::string("$5^^jdfsg:"))  == false);
    CPPUNIT_ASSERT(isUnique(std::string("      "))  == false);
    
    
    CPPUNIT_ASSERT(isUnique(std::string("asd jbv ert"))  == false);

    auto start = std::chrono::steady_clock::now();
   
    CPPUNIT_ASSERT(isUnique(std::string("1234567890 sdfgpo"))  == true);

    auto end = std::chrono::steady_clock::now();
    auto diff = end - start;
    std::cout << std::endl;
    std::cout << "Microseconds: " << std::chrono::duration <double,std::micro> (diff).count() << " us" << std::endl;



}
コード例 #27
0
ファイル: ElementData.cpp プロジェクト: domenic/mojo
PassRefPtr<UniqueElementData> ElementData::makeUniqueCopy() const
{
    if (isUnique())
        return adoptRef(new UniqueElementData(toUniqueElementData(*this)));
    return adoptRef(new UniqueElementData(toShareableElementData(*this)));
}
コード例 #28
0
  bool DDLIndexPopulator::makeIndexStructs( )
  {
    erydbSelectExecutionPlan csep;
    makeCsep(csep);
    ResourceManager rm;
    if (! fEC) 
    {
		fEC = DistributedEngineComm::instance(rm);
		fEC->Open();
    }

    SJLP jbl = joblist::JobListFactory::makeJobList(&csep, rm);

    boost::shared_ptr<erydbSystemCatalog> csc = erydbSystemCatalog::makeerydbSystemCatalog( fSessionID );
    csc->identity(erydbSystemCatalog::EC);

    jbl->putEngineComm(fEC);
    /*
    ResultManager * result = jbl->GetResultManager();
    result->setRunning(1);
    jbl->Execute();	*/
    jbl->doQuery();
    
    erydbSystemCatalog::TableName tableName;
    tableName.schema = fTable.fSchema;
    tableName.table = fTable.fName;
    
    erydbSystemCatalog::OID tableOid = (csc->tableRID ( tableName )).objnum;
    erydbSystemCatalog::NJLSysDataList sysDataList;
    for (;;)
	{
		TableBand band;
		band = jbl->projectTable(tableOid);
		if (band.getRowCount() == 0)
		{
			// No more bands, table is done
			break;
		}
		band.convertToSysDataList(sysDataList, csc);
		break;
	}

    //size_t cnt = fColNames.size(); 
    size_t i = 0;
    vector<ColumnResult*>::const_iterator it;
    vector<int>::const_iterator oid_iter;
    for (it = sysDataList.begin(); it != sysDataList.end(); it++)
    {
		if (isUnique())
	    	fUniqueColResultList.push_back(*it);
	    for ( oid_iter = fOidList.begin(); oid_iter != fOidList.end(); oid_iter++ )
	    {
	    	if ( (*it)->ColumnOID() == *oid_iter )
	    	{
				erydbSystemCatalog::ColType coltype = makeIdxStruct(*it, fColNames.size(), csc);
				addColumnData(*it, coltype, i);
			}
		}
			i++;
    } 

    return (fIdxValueList.size() && NO_ERROR == fResult.result );		

  }
コード例 #29
0
ファイル: UmlRelation.cpp プロジェクト: SciBoy/douml
void UmlRelation::write_relation_as_attribute(FileOut & out) {
  UmlRelation * first = side(TRUE);
  Q3CString s;  
  UmlClass * base;

  if ((first->parent()->stereotype() == "stereotype") &&
      (first->roleType()->stereotype() == "metaclass")) {
    if (this != first)
      return;
    
    base = first->roleType();
    s = "base_" + base->name();
  }
  else {
    base = 0;
      
    switch (_lang) {
    case Uml:
      s = roleName();
      break;
    case Cpp:
      if (cppDecl().isEmpty())
	return;
      s = true_name(roleName(), cppDecl());
      break;
    default: // Java
      if (javaDecl().isEmpty())
	return;
      s = true_name(roleName(), javaDecl());
    }
  }
  
  out.indent();
  out << "<ownedAttribute xmi:type=\"uml:Property\" name=\"" << s << '"';
  out.id(this);
  
  if (base != 0)
    out.ref(first, "association", "EXT_");
  else {
    write_visibility(out);
    write_scope(out);
    if (isReadOnly())
      out << " isReadOnly=\"true\"";
    if (isDerived()) {
      out << " isDerived=\"true\"";
      if (isDerivedUnion())
	out << " isDerivedUnion=\"true\"";
    }
    if (isOrdered())
      out << " isOrdered=\"true\"";
    if (isUnique())
      out << " isUnique=\"true\"";
  
    if (first->_assoc_class != 0)
      out.ref(first->_assoc_class, "association");
    else
      out.ref(first, "association", "ASSOC_");
  
    out << " aggregation=\"";
    if (this == first) {
      parent()->memo_relation(this);
      if (_gen_eclipse) {
	switch (relationKind()) {
	case anAggregation:
	case aDirectionalAggregation:
	  out << "shared";
	  break;
	case anAggregationByValue:
	case aDirectionalAggregationByValue:
	  out << "composite";
	  break;
	default:
	  out << "none";
	}
      }
      else
	out << "none";
    }
    else if (_gen_eclipse)
      out << "none";
    else {
      switch (relationKind()) {
      case anAggregation:
      case aDirectionalAggregation:
	out << "shared";
	break;
      case anAggregationByValue:
      case aDirectionalAggregationByValue:
	out << "composite";
	break;
      default:
	out << "none";
      }
    }
    out << '"';
  }
  
  out << ">\n";
  out.indent(+1);
  
  out.indent();
  out << "<type xmi:type=\"uml:Class\"";
  if (base != 0) {
    if (! base->propertyValue("metaclassPath", s))
      s = (_uml_20) ? "http://schema.omg.org/spec/UML/2.0/uml.xml"
		    : "http://schema.omg.org/spec/UML/2.1/uml.xml";
    out << " href=\"" << s << '#' << base->name() << '"';
  }
  else
    out.idref(roleType());
  out << "/>\n";
  write_multiplicity(out, multiplicity(), this);
  write_default_value(out, defaultValue(), this);
  write_constraint(out);
  write_annotation(out);
  write_description_properties(out);
  
  out.indent(-1);
  out.indent();
  out << "</ownedAttribute>\n";

  unload();
}
コード例 #30
0
ファイル: DataLoader.cpp プロジェクト: marisacgarre/rvtests
/**
 * Rearrange phenotype rows in the order given by @param names
 * @param droppedNamed will store sample names who are in @param names but are
 * not listed in phenotype.
 *
 * NOTE: @param names usually is the VCF sample names
 * NOTE: Current phenotype data may have NAN values
 */
int DataLoader::arrangePhenotype(const std::vector<std::string>& names,
                                 std::vector<std::string>* droppedNames) {
  if (!isUnique(names)) {
    logger->error("VCF file have duplicated sample ids. Quitting!");
    abort();
  }

  // not impute phentoype
  if (!FLAG_imputePheno) {
    std::vector<std::string> noGenotypeSamples =
        setSubtract(phenotype.getRowName(), names);
    *droppedNames = setSubtract(names, phenotype.getRowName());
    const int n = noGenotypeSamples.size();
    if (n) {
      logger->info("Discard [ %d ] samples as they do not have genotypes", n);
    }
    phenotype.dropRow(noGenotypeSamples);
    phenotype.reorderRow(names);
    // TODO: print some info here
    return 0;
  }

  // imputation
  std::vector<std::string> noPhenotypeSamples =
      setSubtract(names, phenotype.getRowName());
  const int n = noPhenotypeSamples.size();
  if (n) {
    logger->info(
        "Impute [ %d ] phenotypes of [ %d ] samples to the mean values",
        phenotype.ncol(), n);
    phenotype.addRow(noPhenotypeSamples, NAN);
    phenotype.imputeMissingToMeanByCol();
  }
  phenotype.reorderRow(names);
  return 0;

#if 0
  // phenotype names (vcf sample names) arranged in the same order as in VCF
  std::vector<std::string> phenotypeNameInOrder;
  std::vector<double>
      phenotypeValueInOrder;  // phenotype arranged in the same order as in VCF

  // TODO: better support  for multiple phenotypes
  std::map<std::string, double> phenoDict;
  for (int i = 0; i < phenotype.nrow(); ++i) {
    phenoDict[phenotype.getRowName()[i]] = phenotype[i][0];
  }

  rearrange(phenoDict, names, droppedNames, &phenotypeNameInOrder,
            &phenotypeValueInOrder, FLAG_imputePheno);
  // rearrange(phenoDict, vcfSampleNames, &vcfSampleToDrop,
  // &phenotypeNameInOrder,
  //           &phenotypeInOrder, FLAG_imputePheno);

  phenotype.resize(phenotypeNameInOrder.size(), 1);
  phenotype.setRowName(phenotypeNameInOrder);
  phenotype.setCol(0, phenotypeValueInOrder);
  if (phenotypeValueInOrder.size() != phenoDict.size()) {
    logger->warn(
        "Drop [ %d ] samples from phenotype file due to missing genotypes from "
        "VCF files",
        (int)(phenoDict.size() - phenotypeValueInOrder.size()));
    // We may output these samples by comparing keys of phenotype and
    // phenotypeNameInOrder
  }

#endif

  return 0;
}