How to generate a random string and compute the percent of a specific string?

Daniel Valencia C.

I'm doing my first ever R course. One of the exercises is to create a random DNA strings with 1000 bases and for it compute the GC percentage (GC%).

I created the DNA bases vector and tried to create the sequence, however, the result is not correct

DNA <- c("A","G","T","C")
seq <- strrep(DNA, 250)

Any suggestion for this noob?

storaged

Basically you should check out very basics of R, i.e sum, sample, paste functions. The solution is quite simple:

DNA <- c("A","G","T","C")
chain <- sample(DNA, 1000, replace = T)
GCcontent <- sum(chain %in% c('G','C'))/length(chain)
# chain as a string
paste(chain, collapse="")

Cet article est collecté sur Internet, veuillez indiquer la source lors de la réimpression.

En cas d'infraction, veuillez [email protected] Supprimer.

modifier le
0

laisse moi dire quelques mots

0commentaires
connexionAprès avoir participé à la revue

Articles connexes

How to generate random number by given string in python?

How do you convert a string percent to a float decimal?

SQL Server : generate random numeric string 27 characters long

Function to generate random string with nested function is giving me trouble

How do I generate a random color in a specific range?

how to get specific string in a string on postgresql

C# : how to use string in random?

Percent (%) operation on a string divided into two numbers

Checking for random string in Python

How to print a specific String stored into an array of String into an ArrayList of Strings Arrays?

How to generate string_3 from the difference between string_1 and string_2?

How to get a specific string in array using powershell?

How to sort from specific values of string?

How to insert lines after specific string with `:` and `=`?

How to see if a specific string matches a regex pattern?

How to fetch a specific substring from string?

How to check if the last char of a String is a specific char

How to get only a specific "row" of a string?

php how to get a string in a specific place

How to replace a specific character in a string (python)

How to type hint specific constant string in TypeScript?

How to replace the duplicated values in a string by a specific character?

How to check a specific format of string in C

How to add a space in a string at a specific position

How to get objects that contain a specific string

How do i make random letter from a string?

How would I extract the date from a string that contains random information?

How can I quickly generate all permutations of a string in Ruby?

compute string length in Spark SQL DSL

TOP liste

  1. 1

    Comment afficher du texte au milieu de div avec une couleur d'arrière-plan différente?

  2. 2

    Modbus Python Schneider PM5300

  3. 3

    Comment faire une recherche partielle et obtenir un score pertinent dans Elasticsearch

  4. 4

    Autocomplete avec java, Redis, Recherche élastique, Mongo

  5. 5

    Comment choisir le nombre de fragments et de répliques Elasticsearch

  6. 6

    Comment utiliser HttpClient avec TOUT cert ssl, quelle que soit la « mauvaise » est

  7. 7

    Existe-t-il un moyen de voir si mon bot est hors ligne ?

  8. 8

    optimiser les opérations du serveur avec elasticsearch: traitement des filigranes de disque bas

  9. 9

    MasterService d'ElasticSearch prend trop de temps pour calculer l'état du cluster et lancer ProcessClusterEventTimeoutException

  10. 10

    Spring @RequestParam DateTime format comme ISO 8601 Date Heure facultative

  11. 11

    Quelque chose dans le cluster Elasticsearch 7.4 devient de plus en plus lent avec les délais de lecture de temps en temps

  12. 12

    Microsoft.WebApplication.targets

  13. 13

    Comment analyser un hachage Ruby plat en un hachage imbriqué?

  14. 14

    Comment changer la couleur de la police dans R?

  15. 15

    Comment créer une nouvelle application dans Dropbox avec des autorisations complètes

  16. 16

    Comment vérifier si un utilisateur spécifique a un rôle? Discord js

  17. 17

    Exporter la table de l'arborescence vers CSV avec mise en forme

  18. 18

    Résultat de l'échantillonneur JMeter : comprendre le temps de chargement, le temps de connexion et la latence

  19. 19

    Ajustement non linéaire avec R

  20. 20

    comment copier du contenu et le mettre dans un pdf nouvellement créé en utilisant iText

  21. 21

    php ajouter et fusionner des données de deux tables

chaudétiquette

Archive